S. Jung
S. Jung

Reputation: 33

How do you setup a GitHub repo and branch for collaboration?

I've been looking this up on Google but haven't found a complete straightforward answer.

So far, this is what I know.

To set up a new repo, you can

Click + on the nav bar in GitHub and follow the instructions.

(No problems there)

To add collaborators, you can

Go to your repo on GitHub -> settings -> collaborators -> search by username

(No problems there)

To add branch for collaborator to use

git branch <branch-name>

(So I created a branch and I can push to it, but it doesn't show up on my collaborator's command line when he does 'git branch' after cloning.)

For collaborator to setup repo on their computer

You clone the directory on your local computer

git clone <url> <customize name>

(That's it right? I get errors with -set--upstream-to when I try to push and I'm not sure what that means and what to do.)

I'm just trying to find a simple step-by-step guide to do all these but there doesn't seem to be one that works.

Upvotes: 2

Views: 1025

Answers (2)

nevihs
nevihs

Reputation: 1051

From github page.

When a repo is cloned, it has a default remote called origin that points to your fork on GitHub, not the original repo it was forked from. To keep track of the original repo, you need to add another remote named upstream

git remote add upstream git://github.com/user/repo.git

You can also specify -v, which shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote:

git remote -v

You can add more remote to push and pull as per your convenience.

git remote add /path/to/git/url

You can find more details here: https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

Upvotes: 1

Ravi Chandra
Ravi Chandra

Reputation: 687

git fetch --all should do the trick. This will fetch all the branches after cloning. This command needs to be executed on your collaborators computer. Take a look at the following question.

Upvotes: 1

Related Questions