Thursday, February 10, 2011

How to push from your local master to remote master

Suppose you have added some files to your local master and want to push it to remote master then use the following git command
git push origin master

Wednesday, February 9, 2011

How to create, work and delete a remote branch in git

- Create a new remote branch "abc"
git push origin origin:refs/heads/abc

- Checkout remote branch in your local directory to work on it
git checkout --track -b abc origin/abc

- To make any changes to branch abc and push to remote branch "abc"
git push

- To get latest changes from the remote branch "abc"
git pull

- Delete local  and remote branch "abc"
git checkout master
git branch -r -d origin/abc
git branch -D abc

- Delete remote branch "abc" from github
git push origin :abc

Wednesday, February 2, 2011

How to see all remote and local branches in git

If you have a centralized remote repository cloned in your local drive then to see all branches available in the remote server and your local drive, run command
git branch -a

Tuesday, February 1, 2011

How to get the master branch from central git server

To get a branch from central git repo (assuming you already cloned the central repo)
  1. Logon to the git repo on your local machine
  2. git branch TESTBRANCH
  3. git checkout TESTBRANCH
  4. Check that you have swtiched to that branch by running command git branch. * should be on the new branch

How to get the master branch to your local machine from central git server

To get local copy of git repo from centralized got server, run the following command
git clone git@<your got server>:some/path/project.git