Skip to content

Instantly share code, notes, and snippets.

@arindam89
Created April 17, 2013 03:23
Show Gist options
  • Save arindam89/5401554 to your computer and use it in GitHub Desktop.
Save arindam89/5401554 to your computer and use it in GitHub Desktop.
Git Tips
----
Exporting the archive
git archive HEAD --format=zip > ../../student_12Oct.zip
git archive HEAD --format=zip > ../../student_18_Oct.zip
git archive v3 --format=zip > ../../student_18_Oct_v3.zip
-----
----
Deleting the untracked files
git clean -f
If you want to also remove directories, run git clean -f -d.
If you just want to remove ignored files, run git clean -f -X.
If you want to remove ignored as well as non-ignored files, run git clean -f -x.
Note the case difference on the X for the two latter commands.
---
----
Git Log Graph like
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
---
---
Exporting less if not set properly for git diff
export LESS="-erX"
git diff --color-words old..new
git config --global color.ui true
git config --global push.default simple
---
git log --walk-reflogs [branch]
--
git diff --find-copies-harder -U999999999 --no-color 5d0eb30..c49342a | post-review -a -
--
Stage this hunk [y,n,a,d,/,j,J,g,e,?]? ?
y - stage this hunk
n - do not stage this hunk
a - stage this and all the remaining hunks in the file
d - do not stage this hunk nor any of the remaining hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk ? - print help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment