相关疑难解决方法(0)

为什么我需要一直做`--set-upstream`?

我在Git中创建了一个新分支:

git branch my_branch
Run Code Online (Sandbox Code Playgroud)

推它:

git push origin my_branch
Run Code Online (Sandbox Code Playgroud)

现在说有人在服务器上做了一些更改,我想从中拉出来origin/my_branch.我做:

git pull
Run Code Online (Sandbox Code Playgroud)

但我得到:

You asked me to pull without telling me which branch you
want to merge with, and 'branch.my_branch.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 …
Run Code Online (Sandbox Code Playgroud)

git git-branch

1364
推荐指数
18
解决办法
93万
查看次数

git - 远程添加origin vs remote set-url origin

我创建了一个新的存储库:

git init
echo "# MESSAGE" >> README.md
git add README.md
git commit -m "first commit"
Run Code Online (Sandbox Code Playgroud)

然后我想将我的提交推送到在github上创建的空远程存储库,所以我必须设置远程.

使用以下命令有什么区别?:

git remote add origin git@github.com:User/UserRepo.git
git remote set-url origin git@github.com:User/UserRepo.git
Run Code Online (Sandbox Code Playgroud)

最后我执行推送:

git push -u origin master
Run Code Online (Sandbox Code Playgroud)

EDIT1:

当我在git init之后调用remote set-url origin时会发生什么?远程set-url origin是否创建了origin?如果在git init之后已经存在origin,那么在我的场景中使用这些命令没有区别,对吧?

git github

345
推荐指数
10
解决办法
43万
查看次数

标签 统计

git ×2

git-branch ×1

github ×1