Git snippets

Git command reference.

# clone
$ git clone

# pull from remote to local
$ git pull
$ git pull origin branch-name

# show changes status 
$ git status

# add files to commit
$ git add .

# commit changes to local branch
$ git commit -am 'quick fix'

# revert all uncommitted changes
$ git checkout .
$ git reset --hard

# download list of branches
$ git fetch

# push the committed to remote
$ git push
$ git push origin 

# create branch and checkout to it
$ git checkout -b 'branch-name'
# create branch without checkout to it
$ git branch 'branch-name'

# save / load changes aside with stash 
$ git stash
$ git stash pop

# show all branches in last modified first order
$ git branch -a --sort=-committerdate

# set name and email
git config --global "name"
git config --global "email"
# set name and email for current repo
git config "name"
git config "email"

# get remote url
git remote get-url origin
# set remote url
git remote set-url origin https://<user><space>/<project_name>.git

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s