Skip to content

Common git commands

Wai-Yin Kwan edited this page Jul 20, 2015 · 3 revisions

local git commands

git status shows you the current status of your branch. Red text are files that you have changed, but haven't added yet. Green text are files that you have added, but not committed.

git log shows you the history of commits

git log --pretty=format:"%h %s" shows you the history of commits in a prettier format

git branch shows you all the branches. green text is your current branch.

git checkout <branch-name> switch to another branch

git checkout -b <new-branch-name> create new branch and switch to the new branch

git branch -D <branch-name> delete a branch branch

git add <file-name or .> add files

git commit -m "description" commit files

git merge <branch-name> merge all the changes from a branch into your current branch

commands to interact with github

git pull origin <branch-name> download the changed files from a branch on github

git push origin <branch-name> upload your changed files to branch on github

setting up git

The default text editor for git is VIM. You can configure git to use another text editor.

Use atom.

git config --global core.editor "atom --wait"

Use sublime

git config --global core.editor "subl -n -w"
Clone this wiki locally