0% found this document useful (0 votes)
8 views1 page

Git Git Cheat Sheet

Uploaded by

serapherny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Git Git Cheat Sheet

Uploaded by

serapherny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Git@facebook Cheat Sheet Restart from SVN clean $ git log --before=5.days.ago --after=6.days.

ago
See which files are modified, which have been added to the The hash of that one commit 100 days ago
index, and which are untracked
Creating a git www repository $ git log --pretty=format:%H --before=100.days.ago -n1
$ git status
$ git-clone-www [destination] Reset all tracked files to SVN (be careful!) Smart grep that ignores .git directory
$ git reset --hard trunk $ git grep -n 'pulse'
Referring to commits See which untracked files would be removed, then remove them Blame
Show current commit $ git clean -n Blame, but ignore whitespace changes and do strong looking
$ git show HEAD $ git clean -f for moved lines
$ git blame -MCC -w afile.txt
Show two commits ago
$ git show HEAD^^ Remove untracked files and ignored files (like conf/dev.php)
Blame data before a commit
$ git blame -MCC -w afile.txt 123bd3^
Show two commits ago $ git clean -fdx
$ git show HEAD~2 See what a file looks like in SVN
Working with SVN
$ git show trunk:path/to/file The SHA1 for SVN revision 11
Common workflow $ git svn find-rev r11
Only reset a single file
Create a branch from SVN The SVN revision for SHA1 of eadfbb
$ git checkout -b firstfix trunk $ git checkout trunk -- path/to/file
$ git svn find-rev eadfbb
Rebase to make current Squashing commits SVN log with SVN and git revisions next to each other
$ git fetch; git rebase trunk Make lots of commits $ git svn log --oneline --show-commit
See what you can add to the index from the working tree $ vim hi.txt && git commit -a -m 'first' Collaboration
$ git diff $ vim hi.txt && git commit -a -m 'second'
Creating a patch file
Add changes to the index Run an interactive rebase up to some point $ git format-patch trunk.. --stdout > ~/a.patch
$ git add filename.txt $ git rebase -i trunk Applying a patch file
Commit changes to git Squash the lower commits up $ git am ~/a.patch
$ git commit
pick dda5e1f first Using .git
See what you’re about to send to differential squash f340a1f second To ignore files from git show
$ git show $ vim .git/info/exclude
Send changes to differential Save, exit, and make your new commit message pretty.
To enable the post commit hooks
To create a branch ready-for-diff that is a squash of everything
$ arc diff from git-svn to your HEAD $ chmod +x .git/hooks/post-commit
When rejected, fix your code with an amended commit For everything you can add to $HOME/.gitconfig
$ git commit -a --amend $ git checkout firstfix
$ git help config
$ git svn rebase
Send to differential again $ git checkout -b ready-for-diff trunk Randomly useful
$ arc diff $ git merge --squash firstfix
Finding/recovering a lost commit with your history
Once accepted, make commit message ready for SVN $ git commit
$ git reflog
$ arc amend
Fun with log and search To binary search for a bug that did not exist 50 commits ago
Log each commit you’re about to commit to SVN
(note the two dots in trunk..) Every commit by zuck $ git bisect start
$ git log --reverse trunk.. $ git log --author=zuck $ git bisect bad && git bisect good HEAD~50
Commit change to SVN Commits that contains the commit message text “super” $ ./execute_test && git bisect {good|bad}
$ git bisect reset
$ git svn dcommit $ git log --grep=super
Work on something new Commits that contains as part of the commit diff “super” To commit info.txt and directory scripts, irregardless of the
$ git checkout -b secondfix trunk $ git log -S'super' state of your index.
$ git commit info.txt scripts/
Remove the old branch Commits touching a specific file
$ git branch -d firstfix $ git log -- path/to/file For changes contact [email protected] or
git clone git:/home/engshare/git/projects/git help docs
Commits from 5-6 days ago

You might also like