Skip to content

Instantly share code, notes, and snippets.

@raviwu
Last active April 25, 2017 20:59
Show Gist options
  • Save raviwu/5e3bb50e410efb3d16d0fb6ae2ef7c61 to your computer and use it in GitHub Desktop.
Save raviwu/5e3bb50e410efb3d16d0fb6ae2ef7c61 to your computer and use it in GitHub Desktop.
Basic Git Commands

git init

git add . add current directory to stage

git add -A add all untrack directories and files to stage

git commit commit staged files

git checkout -b new-branch-name create new branch and checkout to new branch

git checkout existed-branch-name switch to existed branch

git stash reset working directory as latest commited status

git checkout -f force git to checkout HEAD

git push -u origin remote-branch-name

vim ~/.gitignore_global to add file type to be ignored by git globally

vim project_directory/.gitignore to add project specific file to be ignored by git

git merge branch-name to merge the branch-name into current HEAD

git diff to show difference of changes

git branch -d branch-to-be-deleted can delete the merged branch

git branch new-branch-name create new branch but HEAD remain in current branch

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