kshenoy
kshenoy

Reputation: 1816

Git: Pulling from remote

This is my setup: I work at home and in college and the remote is stored online. All 3 locations have three branches called, say, br1, br2 and br3. Nothing fancy, each branch at each workstation is the same. In other words, br1 at home, br1 at work and br1 at remote all correspond to the same branch etc.

Now, when I try to pull br2 at home, I get a message saying that I've to specify which branch I need to merge with. I know what is happening and how to correct it but I can't figure out why it is happening. Does git not merge with a branch of the same name? Do I have to create entries in the config file for every branch I have?

On a side note, what is the difference between git rm --cached and git reset --mixed?

Upvotes: 4

Views: 215

Answers (2)

aschmid00
aschmid00

Reputation: 7158

i think what happened is that you created the branch locally and pushed it to the remote.
in this case the local branch does not have an upstream.

you can set the upstream with

git branch --set-upstream foo origin/foo

-u

--set-upstream

For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch..merge in git-config(1).

Upvotes: 2

ralphtheninja
ralphtheninja

Reputation: 133008

You dont have to manually edit the config files. I'd recommend to delete the branch and check out a tracking branch from scratch. Be careful so you don't have any local changes that needs to be pushed:

git branch -D br2
git checkout --track origin/br2

If you checkout remote branches with --track they will always be setup properly when pushing and pulling.

Upvotes: 0

Related Questions