Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jguitar
Last active December 11, 2015 04:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jguitar/4547764 to your computer and use it in GitHub Desktop.
Save jguitar/4547764 to your computer and use it in GitHub Desktop.
Git sequences

Git

Finding a delete file in history

Find the file_path exactly
git log --diff-filter=D --summary
Find the hash commit
git rev-list -n 1 HEAD -- <file_path>

Create a new branch for n-last commits

git checkout -b <branch-name>
git branch -f master HEAD~3

Diffs and applying

diff/apply commands

git diff > <patchfile>

# one way
git apply <patchfile>

# another harder way
patch -p1 < <patchfile>

The best patching

Creating patches from each commit
git format-patch HEAD~2
git format-patch -n2
Applying patches
git am *.patch

Show diff between master and a branch

git checkout <branch-name>
git pull

git checkout master
git pull

git merge --squash <branch-name>
git diff [--staged]

Show commits from one branch

git whatchanged master.. --format=oneline
To clean
git reset HEAD
git checkout .

Show ignored files

git ls-files --others -i --exclude-standard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment