1

My partner and I are using Git to manage our code for our current project.
I made a branch called test_func that extends a function in the code (didn't know if it would work or not; that's why I did it on a branch).

However, my partner cannot access this branch from his local machine.
When he types git branch, it says that there is only one branch, master.

Is there any way I can make it to where he has access to the branch test_func as well? We both need to be able to read and write to it.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
Ryan
  • 5,671
  • 4
  • 14
  • 26

1 Answers1

0

You need to push it to a common bare repo in order for your colleague to fetch and check out:

# You (first push only)
git push -u origin test_func

The -u is to establish a remote tracking relationship between your local test_func branch and origin/test_func: see "Why do I need to explicitly push a new branch?".
After thatinitial push, simple git push is enough.

# your colleague
...
git fetch
git checkout test_func

If you don't have one centralized bare repo, your colleague can add your repo as a remote, using a shared path.

# your colleague
git remote add you \\shared\path\to\your\repo
git fetch you
git checkout test_func
Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • Thanks! What is the purpose of the `-u` when pushing? I've seen this before, but I usually just stick with `git push origin master` Should I always be using `-u` when pushing? – Ryan Feb 17 '15 at 08:22
  • @Ryan I have edited the answer and link to http://stackoverflow.com/a/17096880/6309 which explains it in detail. – VonC Feb 17 '15 at 08:25