ahgit
DEFINITIONS
-----------
working - the files in your local working dir
stage - files staged in cache for commit
HEAD - HEAD is pointer to current branch
current - current branch points to a particular commit
SEE ALSO: ahproj
TIPS
----
To see old version of file use
git show OLDREV:path/to/file
To see all filenames that were ever in the repo:
git log --name-only --all --format="format:" | sort -u
See all files that were deleted in any commit
git log --all --diff-filter=D --summary | grep delete | sort -u
See all commits that affected a file path/to/foo.c
git log --all -- path/to/foo.c
gitk --all -- path/to/foo.c
See all commits not yet pushed to origin/somebranch
git log origin/somebranch..HEAD
Revert the commit you just did
git reset --soft HEAD^ ; revert branch, but leave working dir unchanged
edit, add, and remove files from index
git commit -c ORIG_HEAD ; commit new change using original message (opens msg in vi first)
Revert any commit
git revert <hash> ; adds a commit which is reverse of <hash>
See the commit id of current branch
git merge-base HEAD HEAD
See the commit id of branch b
git merge-base b b
See common ancestor of branches a and b (as a commit id)
git merge-base a b
See current head (HEAD if none)
git rev-parse --abbrev-ref HEAD
COMMANDS
--------
git add <file> - stage current version of <file> (new or edited)
git status - see staged and unstaged changes
git commit - commit staged changes
git show rev:path/to/file - show version of file at rev
git diff <file> - show differences between working & staged version
git diff --staged <file> - show differences between staged & HEAD version
git diff <c1> <file> - working vs commit <c1>
git diff <c1> <c2> <file> - commit <c1> vs commit <c2>
man git-rev-parse - see SPECIFYING REVISIONS for syntax of <c1>, <c2>
git branch - show branches (* = HEAD branch)
git branch <br> - create new branch named <br> points to current HEAD
(does not switch to new branch!!)
git checkout <br> - move HEAD to branch <br>, and update working
git checkout -b <br> - create <br> and check it out (switch to it)
git branch -d <br> - DELETE branch <br> (loses all unmerged commits)
git-merge <br> - merge <br> into current HEAD branch
Fast Forward: current branch just moves forward to <br>
No conflict: new commit created automatically
Conflict: must merge by hand
git status - see merge conflicts
vw <f> - edit files to resolve conflicts
git mergetool - run merge gui tool to resolve conflicts
git add <f> - stage file that has been resolved
git commit - commit the merge
mgd $(git merge-base HEAD MERGE_HEAD) MERGE_HEAD -- <file>
- look at difference between merge base and 'other'
mgd $(git merge-base HEAD MERGE_HEAD) HEAD -- <file>
- look at difference between merge base and 'mine'
(origin is the cloned remote. Use other remote names too.)
git fetch origin - get latest stuff (do not merge with my stuff)
git pull - get latest stuff and merge into current branch
git remote show origin - info about origin remote
git diff-tree -p <c1> <c2> >f - create patch file f of diff from c1 to c2
git apply f - apply patch f to current branch
To push the local current branch to the garret review server:
git rebase -i xxxx
git push origin HEAD:refs/for/android-tegra-2.6.29
where xxxx is the TOT commit for android-tegra-2.6.29 - find it with
git show origin/android-tegra-2.6.29
GIT LOG
-------
git log since..until - since is earlier; until is later
git log --name-only - just names of changed files
git log --oneline - one per line
git log --first-parent - do not follow merged-in changes