Nicola Peluchetti
Nicola Peluchetti

Reputation: 76870

How to create a new branch in a local repository taking code from a remote branch without doing any merging

I've a branch on a remote repository and i want to bring that branch locally so i can do a rebase. I've added the repo of the remote branch which is called github. If i do

git checkout -b feature/AIOEC-168
git pull github feature/AIOEC-168

a merge occur. I would like to copy feature/AIOEC-168 locally and then on that branch do git rebase develop, how can i do that?

Upvotes: 0

Views: 144

Answers (3)

amalloy
amalloy

Reputation: 91837

On any halfway-recent version of git, you can just git checkout feature/AIOEC-168, which will detect the similarly-named branch in origin and create a local branch of the same name, tracking the origin branch.

Upvotes: 0

Christopher
Christopher

Reputation: 44234

If you want a local version of the remote branch that also sets the remote's branch as upstream, use git checkout's --track flag:

git checkout --track github/feature/AIOEC-168

That will create feature/AIOEC-168 locally, it'll be identical to the github remote's version (and will also set up that version as the upstream tracking branch), and you can rebase from there with any rebase command you'd like.

Upvotes: 1

KL-7
KL-7

Reputation: 47588

Instead of git pull try git fetch:

git fetch github
git rebase github/feature/AIOEC-168

Upvotes: 1

Related Questions