tags:

views:

231

answers:

2

I have a private project hosted on github. I have a production branch of that project. I got a new machine and I need to fix something on production. This is what I did.

git clone [email protected]:userid/project.git
# now I have master branch
git co -b production
git pull origin production

Using the above mechanism I am able to get production branch but I am getting merge conflicts which I do not want to deal with right now.

Is there a cleaner way of jut getting the production branch code on my local machine?

+5  A: 

You could checkout directly the remote branch after fetching it

git fetch origin
git branch -f remote_branch_name origin/remote_branch_name
git checkout remote_branch name

or shorter:

git checkout -b production origin/production

You would be directly working from the fetched copy of origin/production branch (no conflict there).

By doing

git co -b production
git pull origin production

You are trying to merge the remote production branch into your master (in a local 'production' branch, which means potentially conflicts if your master has locally a different history than the remote origin/production branch.

VonC
+3  A: 

git checkout -b production by itself will checkout a new branch called production based on the branch you currently have checked out, the master.

It's likely that what you actually wanted to do was:

git checkout -b production origin/production
Ben James