Git snippets

Git command reference.

# clone
$ git clone git@bitbucket.org:user/repo.git

# 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 user.name "name"
git config --global user.email "email"
# set name and email for current repo
git config user.name "name"
git config user.email "email"

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

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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