RSS

Some more GIT commands

11 Jan
1. TO CREATE A NEW BRANCH
git branch [name of your new branch]

2. TO SWITCH TO THIS BRANCH
git checkout [name of the new branch]

3. TO CREATE A BRANCH AND SWITCH TO THE BRANCH IN ONE MOVE:
git checkout -b [name of new branch]

4. TO PUSH THE NEW BRANCH TO A REMOTE REPOSITORY
git push origin [new-branch]

5. TO MERGE YOUR NEW BRANCH INTO THE MASTER BRANCH
First, switch back to the master branch:
git checkout master
Then merge “xyz” branch to master
git merge xyz

6. TO PULL A NEW BRANCH FROM A REMOTE REPOSITORY
git fetch origin [remote-branch]:[new-local-branch]

7. TO MAKE SURE THAT YOUR NEW BRANCH GETS CHANGES FROM THE MASTER BRANCH (WHERE EVERYBODY ELSE IS WORKING) USE THE REBASE COMMAND
git rebase master

8. TO SWITCH TO ANOTHER BRANCH
git checkout [name of the branch you want to switch to]

9. TO DELETE A BRANCH THAT IS NOT USED ANYMORE, but already merged into the current branch. (TO CLEAN UP)
git branch -d [name of branch you want to delete]

10. TO DELETE AN UNMERGED BRANCH
git branch -D [name of branch you want to delete]
 
Leave a comment

Posted by on January 11, 2010 in Git, Repositories

 

Tags: , , , ,

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

 
%d bloggers like this: