Skip to content

Instantly share code, notes, and snippets.

@phts
Last active January 28, 2016 15:58
Show Gist options
  • Save phts/39d49db17cb120819eca to your computer and use it in GitHub Desktop.
Save phts/39d49db17cb120819eca to your computer and use it in GitHub Desktop.
Git commands that are being used every day

HEAD^ - First parent commit

HEAD~x - xth parent commit

git reset HEAD -- file - Unstage file

git checkout -- file - Revert local changes (checkout file from the current branch)

git checkout branch -- file - Get a file from other branch

git format-patch -1 <SHA> - Make a patch file

git am <file> - Apply a patch file

git checkout-index -a -f --prefix=<destination e.g. /var/www> - Export sources to other folder from local repo (not bare)

git archive --format=tar --remote=ssh://:/<repo_path> master | tar -xf - - Export sources to the current folder (e.g. /var/www/myapp) from remote repo

  • ssh://[user@]host.xz[:port]/path/to/repo.git/
  • git://host.xz[:port]/path/to/repo.git/
  • http[s]://host.xz[:port]/path/to/repo.git/
  • ftp[s]://host.xz[:port]/path/to/repo.git/
  • rsync://host.xz/path/to/repo.git/
  • [user@]host.xz:path/to/repo.git/
  • ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
  • git://host.xz[:port]/~[user]/path/to/repo.git/
  • [user@]host.xz:/~[user]/path/to/repo.git/

From berkshelf/berkshelf#257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment