简体   繁体   中英

git pull: tell it which branch to merge with

So the problem is, I have a git repository and I want to upload it to GitHub. I've ran through multiple threads on SOF and it suggested git push -u origin master. The problem is, when I do that it tells me I need to merge first so I don't lose any data. So it suggested to me to git pull. I did and this is what I get:

You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:
    [branch "master"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.

How do I fix this?

EDIT: Never mind I just fixed this. If you guys encounter a problem like this do: git pull

Assuming your branch is called master and the remote is called origin:

git pull origin master

If you have not set a remote yet, the command to do so is:

git remote add origin git@github.com:username/repository.git

Origin in both cases is just a common name for the github remote. Replace username with your username and repository with your repository name. After that, you will be able to refer to your github repository as "origin".

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