Use git bisect to quickly determine what commit introduced a change, usually a bug.
git bisect startgit bisect good a1b54ff3 Mark an earlier commit that worksgit bisect bad master Mark a later commit that doesn't work
git bisect bad|good|skip for eachgit bisect reset To end the session.gitattributes can be overridden in .git/info/attributesThis will update the current branch, without changing any files. The difference between the two points will be left as uncommitted changes.
git checkout workingTreegit checkout --detachgit reset --mixed destinationgit checkout destinationGit's diff can be used on arbitrary files or folders, even if they are in separate repos or no repos at all.
git diff --no-index current/ base/
This re-writes a traditional merge commit into a squashed merge commit. Any dependent tree's will have to be rebased onto the new commit. Also this will require force push.
git reset --hard HEAD~1git cherry-pick -m 1 HEAD@{1}git svn clone <svn url> -s --prefix=origin/
git svn clone <svn url>/trunk --prefix=origin/ # clone without tags and branches
git svn fetch # gets new svn commits onto origin/git-svn, can continue a failed clone sometimes
# ...use git normally...
git svn rebase # pulls down, rebases current work on top, creates local commits. instead of pull
git svn dcommit
# ...if using topic branches, rebase them onto master instead of merging.
# ...don't push to git repos, since commits get rewritten when using dcommit
git svn find-rev r1234Adapted from Git rebase docs
In the following situation, there is a stacked feature branch, and topicA has been squash merged to main. We want to rebase the commits from topicB back onto main.
H---I---J topicB
/
E---F---G topicA
/
A---B---C---D---EFG’ main
The command git rebase --onto main topicA topicB makes the following change
E---F---G topicA
/ H'--I'--J' topicB
| /
A---B---C---D---EFG’ main
This could also be useful when topicB does not depend on topicA, regardless of topicA being merged.