提交不被推到原点
Commits not being pushed to origin
我在本地更改了一些文件,添加了它们并提交了它们。当我尝试将此分支推送到原点以便我可以打开合并请求时,似乎它没有推送任何更改,因为总计为 0
~/work/pr $ git commit -m "something"
[master e9bd370] something
5 files changed, 86 insertions(+), 11 deletions(-)
create mode 100644 arrows.png
create mode 100644 foo.html
~/work/pr $ git push origin newbranch
Total 0 (delta 0), reused 0 (delta 0)
To git@hosted.gitlab.repo:user/my-repo.git
* [new branch] newbranch -> newbranch
上面让我在 GitLab 网页上打开一个新的合并请求,但是,说 "nothing to merge"。这是因为上面终端输出中的 Total 0
。
根据您的提交结果,看起来您在提交时处于 master
。
由于您将其提交给 master
,而不是 newbranch
,newbranch
中的任何内容都没有更改。
如果要更新 newbranch
分支,则需要在提交/推送之前检出该分支。
这看起来很正常。您的 "newbranch" 显然没有任何新内容可以添加到对话中。
我假设你在这里:
git checkout master # whatever the current branch is, assuming master
您可能打算这样做,从上面开始:
git commit -m "Something"
git branch -f newbranch # re-position the new branch
git push origin newbranch
但这不是最佳做法。你应该做的:
git checkout newbranch
# get the "newbranch" updated with the latest available "good stuff"
git merge master
# work on something and commit
git commit -m "Something"
git status
# "git graph" here would be very useful to look at (see extra hint, below)
git push origin newbranch
PS。额外提示 - 使用方便的别名 git graph
在工作时可视化您的分支,基本上是一个超级强大的 git log
/ git status
(更像日志,不太像状态)。 https://sites.google.com/site/sudokillall9/articles/gitgraphvariants
我在本地更改了一些文件,添加了它们并提交了它们。当我尝试将此分支推送到原点以便我可以打开合并请求时,似乎它没有推送任何更改,因为总计为 0
~/work/pr $ git commit -m "something"
[master e9bd370] something
5 files changed, 86 insertions(+), 11 deletions(-)
create mode 100644 arrows.png
create mode 100644 foo.html
~/work/pr $ git push origin newbranch
Total 0 (delta 0), reused 0 (delta 0)
To git@hosted.gitlab.repo:user/my-repo.git
* [new branch] newbranch -> newbranch
上面让我在 GitLab 网页上打开一个新的合并请求,但是,说 "nothing to merge"。这是因为上面终端输出中的 Total 0
。
根据您的提交结果,看起来您在提交时处于 master
。
由于您将其提交给 master
,而不是 newbranch
,newbranch
中的任何内容都没有更改。
如果要更新 newbranch
分支,则需要在提交/推送之前检出该分支。
这看起来很正常。您的 "newbranch" 显然没有任何新内容可以添加到对话中。
我假设你在这里:
git checkout master # whatever the current branch is, assuming master
您可能打算这样做,从上面开始:
git commit -m "Something"
git branch -f newbranch # re-position the new branch
git push origin newbranch
但这不是最佳做法。你应该做的:
git checkout newbranch
# get the "newbranch" updated with the latest available "good stuff"
git merge master
# work on something and commit
git commit -m "Something"
git status
# "git graph" here would be very useful to look at (see extra hint, below)
git push origin newbranch
PS。额外提示 - 使用方便的别名 git graph
在工作时可视化您的分支,基本上是一个超级强大的 git log
/ git status
(更像日志,不太像状态)。 https://sites.google.com/site/sudokillall9/articles/gitgraphvariants