Git Cheat Sheet
talks about: GitThe following is a reference of Git commands that I’m using every now and then. For a complete guide take a look at the online documentation.
Suppress tracking
A text file named .gitignore suppresses accidental versioning of files and paths matching the specified patterns. GitHub can help you set up your .gitignore
files.
*.log
build/
temp-*
git ls-files –other –ignored –exclude-standard
-
Lists all ignored files in this project.
Mirror changes
git remote set-url origin --push --add git@example.com/project.git
git remote set-url origin --push --add git@another.com/project.git
Adds two new remote repositories as targets for git push
. Every call of git push
will push changes into both specified repositories.
Bisect changes
git bisect start --term-good=unfixed --term-bad=fixed
[1]-
Use
fixed
andunfixed
instead ofgood
andbad
Using host aliases
You can configure host aliases by updating your ~/.gitconfig
like this:
[url "git@github"]
insteadOf = github
Instead of cloning from git@github.com:ORGANIZATION/PROJECT.git
, you can use github:ORGANIZATION/PROJECT.git
. Specify which key is used by updating your ~/.ssh/config
like this:
Host github
Hostname github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/key-for-github
Git will resolve github
into git@github
and your SSH client will resolve github
as github.com
and use the specified key. The same approach can be used to configure different keys on a per project or organization basis.