Home Page - Git
I have documented the activities that I performed when migrating from CVS to Git.
I perform most Git activities via the command line but I have also been using SourceTree as a GUI.
Home Page - SourceTree
Links:
To avoid being prompted for username and password for every “push” it is advisable to use SSH keys.
Create your SSH key as follows:
ssh-keygen -t rsa -b 4096 -C "someone@somewhere.com"
Start the ssh-agent and add the key:
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
Tip: You can add the above lines to ~/.profile so that it is done automically.
Copy / paste the public key into the SSH Keys page on GitHub:
cat ~/.ssh/id_rsa
Change the colours for command line output using the following commands:
# git config --global color.ui auto
git config --global color.diff.old "cyan"
git config --global color.status.untracked "cyan"
git config --global color.status.changed "yellow bold"
It may be preferable to filter / ignore minor changes sometimes, such as changes to line feeds:
git -c core.fileMode=false -c core.safecrlf=false status
git -c core.fileMode=false -c core.safecrlf=false diff
To filter / ignore changes to file permissions you can do something similar:
git -c core.fileMode=false status
git -c core.fileMode=false diff
If you still get prompted for the username then Git might be using https instead of ssh.
Edit the URL line(s) in .git/config:
url = https://github.com/USERNAME/REPOSITORY.git
...
url = ssh://git@github.com/USERNAME/REPOSITORY.git
A couple of my projects use Git tags to trigger automated builds on DockerHub:
Both use lightweight tags as described in the basics of tagging.
git tag <tagname>
git push origin <tagname>
The git revision can be useful for CI/CD builds since it is unique and can be useful as a Docker tag.
Here are two simple commands to get the Git commit id:
git describe --always --abbrev=12
git rev-parse --short=12 HEAD
It is sometimes desirable to delete files from the Git repository.
This might be necessary if large files have been committed by accident or if a project needs to be split.
I have made some notes on shrinking a repository.