edA-qa mort-ora-y
edA-qa mort-ora-y

Reputation: 31921

Multiple git origins/remotes and checkout branches

I have multiple forks of a project and I need to branch from a starting point in one of those forks. I'm not certain how one can do this with "git". Basically, the situation is as follows:

Now YOURS has a branch called NEXT which I want to work on. How do I checkout YOURS/NEXT in my LOCAL clone? Ideally I will be branching form this point and pushing my changes to MINE, issues a pull request, then you merge them to YOURS.

Upvotes: 3

Views: 262

Answers (2)

VonC
VonC

Reputation: 1327184

You need to:

  • declare a remote referring to "YOURS"
  • declare a local branch which will track YOURS/NEXT

That would be:

git remote add YOURS /url/for/YOURS/repo
git fetch YOURS
git checkout -b next YOURS/NEXT

Upvotes: 5

j883376
j883376

Reputation: 1125

Assuming that the git repositories are published somewhere which you can pull from, you can add remote repositories with git remote add [name] [URL], then you're able to pull changes in from the repository you've added with git pull [name] [branch]

A working example of this would be something like

git remote add upstream git://github.com/git/git.git
git pull upstream maint

Upvotes: 2

Related Questions