GIT common commands with Stash

Posted: February 14, 2013 in web

Clone remote branch
git clone http://username/stash/scm/test/branchA.git
cd branchA

Show other remote branches
git branch -a

Pruning stale remote branches
git remote prune origin

Replace all from remote repository
git reset -hard HEAD
git clean -fd
git pull

Cancel merge
git merge –abort

Check and compare remote branches to your local branch
git remote show origin

Compare local changes with the last commit
git diff –name-status (only shows files without the details)
gid diff (shows all details)

Compare local changes with the last commit
git checkout branchA
git fetch
git diff origin/branchA –name-status (only shows files without the details)
gid diff origin/branchA (shows all details)

Get updates from remote branch
git checkout branchA
git fetch
git merge origin/branchA

Commit change and push to remote branch
git checkout branchA
//do some changes
git add -all
git commit -m ‘bug fix’
git push origin branchA

Checking whitespace
git diff –check

Create Branch
$ git checkout -b iss53
//Switched to a new branch “iss53”
//This is shorthand for:
git branch iss53
git checkout iss53

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s