Skip to content

Instantly share code, notes, and snippets.

@tanyuan
Last active February 29, 2016 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanyuan/f9a236872901882d6247 to your computer and use it in GitHub Desktop.
Save tanyuan/f9a236872901882d6247 to your computer and use it in GitHub Desktop.
Useful git and GitHub commands.

GitHub Notes

Command line app

  • git: the main program.
  • tig: git viewer.
  • gist: upload code to GitHub Gist.
  • hub: integrate GitHub. Can be alias to git.

git

Solve conflict by edit manually:

<<<<< HEAD

old code

=====

new

>>>>>

Show diff from last commit:

git diff

Compare file in two branches:

git diff BRANCH..BRANCH FILE

Get changes from a specific commit:

git cherry-pick COMMIT-SHA

Stash:

git stash
git stash list
git stash apply

Ignore files:

.gitignore

Remove file from added:

git rm --cached FILE

Undo last commit without losing changes:

git reset --soft HEAD^

tig

  • Tab: switch window.
  • h: Switch to help view

gist

Associate with GitHub account:

gist --login

Create gists anonymously with -a.

Create a gist from a file:

gist -d "Description." FILE

Update a gist:

gist -u GIST_ID FILE

Add images to a gist:

  1. Clone the gist.
  2. Commit the images.
  3. Push.

hub

  • hub browser: view repo in browser.
  • hub issue: view issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment