Git Can';t将本地更改推送到现有远程分支

Git Can';t将本地更改推送到现有远程分支,git,remote-branch,Git,Remote Branch,有一个叫做“my remote”的远程分支,我以前毫无问题地将其推到了该分支。到今天为止,我不能推,我得到了不同的错误 我遇到的第一个错误是: 我做了一些研究并运行了这个程序,希望它能解决这个问题: git config push.default tracking 运行之后,我再次运行推送: git push https://github.com/someurl/mybranch.git 我得到了以下错误: pushing to remote 'https://github.com/some

有一个叫做“my remote”的远程分支,我以前毫无问题地将其推到了该分支。到今天为止,我不能推,我得到了不同的错误

我遇到的第一个错误是:

我做了一些研究并运行了这个程序,希望它能解决这个问题:

git config push.default tracking
运行之后,我再次运行推送:

git push https://github.com/someurl/mybranch.git
我得到了以下错误:

pushing to remote 'https://github.com/someurl/mybranch.git', which is not the upstream of
your current branch 'my-remote', without telling me what to push
to update which remote branch.
C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git push --set-upstream origin master
Password for 'https://User@bitbucket.org':
To https://User@bitbucket.org/User/app.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://User@bitbucket.org/User/
app.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
我已尝试运行此:

git push master:my-remote https://github.com/someurl/mybranch.git
但它告诉我:

fatal: remote part of refspec is not a valid name in https://github.com/someurl/mybranch.git

如果要在“我的远程分支”上推送主分支,正确的语法为:

 git push https://github.com/someurl/mybranch.git master:my-remote 
(第一:远程回购参考,参考规范,来源)

关于您的第一条错误消息,如果它真的没有告诉您合并,那么可能需要一个
git pull--rebase

或至少一个:

 git config --global push.default current
(如“”所述)

如果您在本地分支“
my remote
”(根据命令,情况就是这样),您可以通过以下方式确保设置了上游分支:

git push -u https://github.com/someurl/mybranch.git my-remote:my-remote

推进现有的git回购有9个步骤

我尝试了“git push--设置上游原始主机”,但出现以下错误:

pushing to remote 'https://github.com/someurl/mybranch.git', which is not the upstream of
your current branch 'my-remote', without telling me what to push
to update which remote branch.
C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git push --set-upstream origin master
Password for 'https://User@bitbucket.org':
To https://User@bitbucket.org/User/app.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://User@bitbucket.org/User/
app.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
然后我尝试了“git pull”,得到了最新的更改:

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git pull
Password for 'https://User@bitbucket.org':
warning: no common commits
remote: Counting objects: 344, done.
remote: Compressing objects: 100% (275/275), done.
remote: Total 344 (delta 45), reused 336 (delta 41)
Receiving objects: 100% (344/344), 15.91 MiB | 43.00 KiB/s, done.
Resolving deltas: 100% (45/45), done.
From https://bitbucket.org/User/app
 * [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

git pull <remote> <branch>
“git add-A”和“git commit”不起作用,因为没有要提交的内容

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git add -A

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git commit
论分行行长 没有要提交的内容,正在清理目录

“git branch——将上游设置为=origin/master”似乎起到了作用

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git branch --set-upstream-to=origin/master master
Branch master set up to track remote branch master from origin.
然而,“git推送源主机”不起作用,因为当前分支的尖端在远程对应的后面

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git push origin master
Password for 'https://User@bitbucket.org':
To https://User@bitbucket.org/User/app.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://User@bitbucket.org/User/
app.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
合并回购协议需要“git拉动”

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git pull
Password for 'https://User@bitbucket.org':
Merge made by the 'recursive' strategy.
在执行“git pull”之后,“git push origin master”正是在visualstudio git插件中获得同步命令所需要的

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git push origin master
Password for 'https://User@bitbucket.org':
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 539 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To https://User@bitbucket.org/User/app.git
   40d72a2..9748b8b  master -> master

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>

谢谢,我运行了此操作,但仍然收到以下错误:错误:未能将某些引用推送到“”提示:更新被拒绝,因为当前分支的提示位于提示:其远程对应项的后面。合并远程更改(例如“git pull”)提示:再次按下之前。我敢肯定,自从我上次提交以来,没有人编辑这个分支。我在github上看不到任何新的提交。如何合并?@user1404536我对该答案做了另外两次编辑,包括一个
git pull--rebase
选项,该选项应将本地分支放在远程分支之上。当我运行git pull--rebase时,告诉我该分支正在运行date@user1404536
git分支-a
返回什么(换句话说,您当前的本地和远程分支是什么?)。有点像运行
git branch-A
时,会显示所有远程分支的列表,在我的远程分支旁边有一个星号。
C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>git push origin master
Password for 'https://User@bitbucket.org':
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 539 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To https://User@bitbucket.org/User/app.git
   40d72a2..9748b8b  master -> master

C:\Users\User\Documents\Visual Studio 2013\Projects\app\User-app-40d72a288916>