相关疑难解决方法(0)

让现有的Git分支跟踪一个远程分支?

我知道如何创建一个跟踪远程分支的新分支,但是如何使现有分支跟踪远程分支?

我知道我可以编辑.git/config文件,但似乎应该有一个更简单的方法.

git branch git-branch

3437
推荐指数
19
解决办法
129万
查看次数

你如何创建一个远程Git分支?

我创建了一个本地分支,我想在上游"推".Stack Overflow上有一个关于如何跟踪新创建的远程分支的类似问题.

但是,我的工作流程略有不同.首先,我想创建一个本地分支,当我满意并希望分享我的分支时,我只会将其推送到上游.

  • 我该怎么办?(我的谷歌搜索似乎没有提出任何东西).
  • 我如何告诉我的同事从上游存储库中取出它?

更新使用Git 2.0,我在下面写了一个更简单的答案:https://stackoverflow.com/a/27185855/109305

git branch git-branch

3030
推荐指数
18
解决办法
200万
查看次数

git push -u是什么意思?

我有两个不同版本的git.在1.6.2版本中,git push没有-u选项.它只出现在1.7.x版本中.

从文档中,-u它与变量有关

branch.<name>.merge
Run Code Online (Sandbox Code Playgroud)

git config.该变量如下所述:

Defines, together with branch.<name>.remote, the upstream branch 
for the given branch. It tells git fetch/git pull which branch to merge.
Run Code Online (Sandbox Code Playgroud)

什么是上游分支?

git

317
推荐指数
3
解决办法
10万
查看次数

git上游,push中使用-u标志

什么是使用-u标志同时推送到一些git repo的提交?我的意思是什么是git push origin mastergit push -u origin master?有人可以描述一下它的用法吗?

git

31
推荐指数
1
解决办法
8052
查看次数

在`git push -u origin master`中使用`-u`有什么用?

可能重复:
"你"究竟做了什么?"git push -u origin master"vs"git push origin master"

在Github中,当您创建一个空存储库时,指令会要求您执行

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

所以我的问题是,-u选项有什么用?

阅读完联接页后,我仍然没有得到它.

git

15
推荐指数
1
解决办法
6724
查看次数

什么是git上游

当你创建了一个github-repo并将github-repo添加为远程时

git remote add origin https://github.com/githubname/reponame.git
Run Code Online (Sandbox Code Playgroud)

然后你需要推送你的第一次提交

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

我读过(为什么我需要一直做`--set-upstream`?)这是一个简短的表格

git branch --set-upstream-to my_branch origin/my_branch
git push
Run Code Online (Sandbox Code Playgroud)

什么是上游,我为什么需要设置它?网上几乎没有关于此的信息.我知道有一个类似的话题'git remote add upstream'帮助实现了什么?,但在我看来,它并没有准确解释上游是什么以及什么git push -u origin master做,特别是origin master指出的是,它是本地回购还是远程回购?

git

15
推荐指数
1
解决办法
9802
查看次数

无法将本地更改推送到现有远程分支

有一个名为"my-remote"的远程分支,我以前没有问题.截至今天,我无法推动,我得到不同的错误.

我得到的第一个错误是:

hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration
hint: variable to 'current' or 'upstream' to push only the current branch.
Run Code Online (Sandbox Code Playgroud)

我做了一些研究,并希望它可以解决问题:

git config push.default tracking
Run Code Online (Sandbox Code Playgroud)

跑完之后我又跑了一下:

git push https://github.com/someurl/mybranch.git
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

pushing to remote 'https://github.com/someurl/mybranch.git', which is not the upstream of
your current branch 'my-remote', without telling me what …
Run Code Online (Sandbox Code Playgroud)

git remote-branch

7
推荐指数
1
解决办法
2万
查看次数

如何将本地存储库上的 URL 从 GitLab 更改为 GitHub?

我在 GitLab 上有一个存储库,我也在 GitHub 上发布了它。

到目前为止,我使用的所有 Git 命令都在 GitLab 上进行了更改。但是,我希望在 GitHub 上进行这些提交。

我试过命令:

git remote set-url origin git@github.com:repo-url
Run Code Online (Sandbox Code Playgroud)

有人可以建议我如何设置 URL 以便命令可以在 GitHub 而不是 GitLab 上运行吗?

git git-pull git-push git-fetch git-remote

3
推荐指数
1
解决办法
3778
查看次数