Git - jrwhetse/jrwhetse.github.io GitHub Wiki

Overview

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency

References

Website: https://git-scm.com/

About: https://git-scm.com/about

Documentation: https://git-scm.com/doc

Downloads: https://git-scm.com/downloads

Linux

Installation

yum install git -y

Setup Global Configuration Properties

As user running git, set User Name, Email Address and push.default method using the following commands.

git config --global user.name "<firstname> <lastname>"
git config --global user.email "<email_address>"
git config --global push.default matching
git config --global --list

Optional: Configure git To Trust Self Signed Certificates issued by Custom CAs

As root, place file containing all custom CAs in the /etc/pki/tls/certs directory.

As root, Ensure all certificates in /etc/pki/tls/certs have read access.

chmod 644 /etc/pki/tls/certs/*

As root, Configure git to use CA's listed in the /etc/pki/tls/certs/ directory for certificate validation.

git config --system http.sslCAPath /etc/pki/tls/certs/ 
git config --system --list

As root, Ensure system wide git configuration file has read access.

chmod 644 /etc/gitconfig

Windows

Installation

Download and Install the latest Git Client: https://git-scm.com/download/win. The installation directory will be referred to as the $GIT_INSTALL_DIR.

Git Bash Shell

Git Bash is a command shell interface for interacting with Git. To access the shell, find Git Bash from the start menu or right mouse click any directory and select Git Bash. From here on, this will be referred to as the Git Bash Shell and it is assumed that all commands will be executed from within the Git Bash Shell.

Set Global Configuration Properties

git config --global user.name "<firstname> <lastname>"
git config --global user.email "<email_address>"
git config --global push.default matching
git config --global --list

Optional: Configure git To Trust Self Signed Certificates issued by Custom CAs

Place Custom CA Bundle file in the $GIT_INSTALL_DIR/usr/ssl/certs directory. Append the contents of Custom CA Bundle.crt to the $GIT_INSTALL_DIR/usr/ssl/certs/ca-bundle.crt file. NOTE: This file gets updated when you update your Git client and this step will have to be redone. This is due to a bug in the Windows Git client where http.sslCAPath {dir}, which would normally read all CA's in a directory, does not work. Optionally, place the cert file in a directory outside the install dir and reference it.

git config --global http.sslCAInfo $GIT_INSTALL_DIR/usr/ssl/certs/ca-bundle.crt
git config --global --list

TortoiseGit

After installing and configuring the GUI client, install TortoiseGit which integrates with Windows Explorer. The right click menu options allow for quick and easy interaction with Git. See https://github.com/TortoiseGit/TortoiseGit for more information

Commands

Create New Project

mkdir {project}
cd {project}
git init
git remote add origin https://[username|PAT]@{fqdn}/{project}.git
git commit -m '{comment}' .
git push

Clone Existing Project

Perform a clone to retrieve a local copy of the project for modifications.

git clone https://[username|PAT]@{fqdn}/{project}.git

Update

git pull

Add/Edit

# file
git add [files|*]
git commit -m '{comment}'
git push

# directory
git add -r [dir|*]
git commit -m '{comment}'
git push

Remove

# file
git rm {file}
git commit -m '{comment}'
git push

# directory
git rm -r <dir>
git commit -m '{comment}'
git push

Add .gitkeep to add dirs to ensure empty dirs show up correctly in github

find . -type d -empty -not -path "./.git/*" -exec touch <>/.gitkeep \;

Remove large files from Git History

Download Jar: https://rtyley.github.io/bfg-repo-cleaner/
git clone --mirror https://github.com/ByLightSDC/bl-devops-ansible.git

$ java -jar bfg-1.13.0.jar --strip-blobs-bigger-than 600K bl-devops-ansible.git



Using repo : C:\Users\enrique.kinsey\bl-devops-ansible.git



Scanning packfile for large blobs: 8682
Scanning packfile for large blobs completed in 128 ms.
Found 3 blob ids for large blobs - biggest=67439361 smallest=654923
Total size (unpacked)=107509875
Found 468 objects to protect
Found 16 commit-pointing refs : HEAD, refs/heads/debug_jpc_rancher_install, refs/heads/feature_complete_teseted_aws_rm_playbooks, ...



Protected commits
-----------------



These are your protected commits, and so their contents will NOT be altered:



* commit 7a2e0202 (protected by 'HEAD') - contains 2 dirty files :
	- roles/weblogic/files/_automation.tar.gz (639.6 KB)
	- roles/weblogic/files/p28710923_121300_Generic.zip (37.6 MB)



WARNING: The dirty content above may be removed from other commits, but as
the *protected* commits still use it, it will STILL exist in your repository.



Details of protected dirty content have been recorded here :



C:\Users\enrique.kinsey\bl-devops-ansible.git.bfg-report\2020-04-13\11-44-48\protected-dirt\



If you *really* want this content gone, make a manual commit that removes it,
and then run the BFG on a fresh copy of your repo.




Cleaning
--------



Found 1003 commits
Cleaning commits:       100% (1003/1003)
Cleaning commits completed in 5,704 ms.



Updating 15 Refs
----------------



	Ref                                                    Before     After
	--------------------------------------------------------------------------
	refs/heads/debug_jpc_rancher_install                 | 26a1be01 | dc162b4b
	refs/heads/feature_complete_teseted_aws_rm_playbooks | 36467582 | 9844bf9c
	refs/heads/feature_mgmt_plus_aws_remove              | df0af472 | 6993fa67
	refs/heads/feature_terraform_mgmt                    | 4d55d83c | b8909ec2
	refs/heads/feature_test_full_devops_provision        | 448ef305 | bea3b9dc
	refs/heads/master                                    | 7a2e0202 | ed21c56c
	refs/heads/rm-branch                                 | 5cfef56a | 7c487a42
	refs/pull/2/head                                     | 8b0b0b9e | 4cddad54
	refs/pull/4/head                                     | df0af472 | 6993fa67
	refs/pull/5/head                                     | 448ef305 | bea3b9dc
	refs/pull/6/head                                     | 186c687d | 35da27a1
	refs/pull/7/head                                     | 26a1be01 | dc162b4b
	refs/pull/8/head                                     | 09c6acca | cf6516b7
	refs/pull/9/head                                     | 5cfef56a | 7c487a42
	refs/tags/0.0.1                                      | ca68165b | 68229d89



Updating references:    100% (15/15)
...Ref update completed in 191 ms.



Commit Tree-Dirt History
------------------------



	Earliest                                              Latest
	|                                                          |
	....DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD



	D = dirty commits (file tree fixed)
	m = modified commits (commit message or parents changed)
	. = clean commits (no changes to file tree)



							Before     After
	-------------------------------------------
	First modified commit | e76fb190 | 639fa6cd
	Last dirty commit     | ecabb039 | ac26c905



Deleted files
-------------



	Filename                                Git id
	-----------------------------------------------------------
	_automation.tar.gz                    | d54942e0 (639.6 KB)
	code-server-3.0.0-linux-x86_64.tar.gz | 182d076a (64.3 MB)
	p28710923_121300_Generic.zip          | 4de3e837 (37.6 MB)




In total, 2152 object ids were changed. Full details are logged here:



	C:\Users\enrique.kinsey\bl-devops-ansible.git.bfg-report\2020-04-13\11-44-48



BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive




--
You can rewrite history in Git - don't let Trump do it for real!
Trump's administration has lied consistently, to make people give up on ever
being told the truth. Don't give up: https://github.com/bkeepers/stop-trump
--


git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push
⚠️ **GitHub.com Fallback** ⚠️