简体   繁体   中英

Git Pull request the branch name

I have a problem with the command "git pull". i have two stash users and in one user it works fine and in the other it gives an error message saying: You asked me to pull without telling me which branch you want to merge with. Please specify which branch you want to use on the command line and try again (eg 'git pull '). See git-pull(1) for details.

i spotted the problem but dont know how to fix it. When i checkout to my branch it is not writing it into the .git/config file. however, this is happening only when I create the branch, when others create the branches i can access them and it is written in the .git/config file.

why is this happening? Thanks,

It's likely that the user with a problem has the branch checked out locally, but it is not tracking the remote branch. You can fix this with the following:

git branch --set-upstream branchname origin/branchname

It is possible that the local branch was created for this user before the remote branch existed — or before a git fetch found it. (This is because git checkout branchname has different behaviour depending on whether a remote branch with the same name is found.)

An alternative approach is to delete the local branch and re-checkout from the remote:

git branch -d branchname
git checkout branchname

The newly checked-out branch will now be tracking the remote branch origin/branchname .

If you're paranoid about losing any local changes, you can make sure you don't lose them by creating a new branch before you delete the old one:

git branch branchname_backup branchname

As always, I highly recommend tig to get a better understanding of what your branches are doing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM