学习 Git:尽管配置正确,远程还是拒绝我的推送?
Learning Git: Remote rejects my push despite proper config?
我只是在学习Git
所以请多多包涵。我在本地编写了一些代码,现在我想将它推送到我的远程服务器 (origin
)。我收到此错误:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'ssh://website@host.website.com:2200/home/user'
Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing
遥控器是 v 2.4.1
并具有此设置(git config --list
的输出):
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
receive.denycurrentbranch=updateInstead
最后一个不是意味着我应该被允许在不引发错误的情况下覆盖冲突吗?
我基本上是在寻找最简单的设置:我不在服务器上开发,而且我是唯一可以访问它的人,所以我想要开发机器推动的任何东西。
我看到 this answer 关于使远程存储库裸露,但说明是删除文件夹中的所有内容,但 .git
。这对我不起作用,因为其中有些文件不属于我的项目,但我不想移动它们
如果我登录到远程存储库并执行 git status
我明白了
Untracked files: (use "git add ..." to include in what will be committed)
...(long list of files)
nothing added to commit but untracked files present (use "git add" to track)
附录
我刚刚做了:
$ git push --force origin master
stdin: is not a tty
Counting objects: 3801, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3674/3674), done.
Writing objects: 100% (3801/3801), 6.95 MiB | 37.00 KiB/s, done.
Total 3801 (delta 2450), reused 0 (delta 0)
error: Untracked working tree file 'cacert.pem' would be overwritten by merge.
To ssh://website@host.website.com:2200/home/user
! [remote rejected] master -> master (Could not update working tree to new HEAD)
error: failed to push some refs to 'ssh://website@host.website.com:2200/home/'
我想我可以删除该文件的服务器副本并重试吗?这两个文件具有相同的内容(这是一个 copy/paste 作业)
I don't want the local to import any change from the remote I want local files to overwrite remote files
问题是,如果您不想 git 拉取该错误消息,则需要:
git push --force
但这不仅会覆盖文件,还会覆盖您提交的远程端最近的提交历史记录,因此请确保这确实是您想要的。
the remote has setting receive.denycurrentbranch=updateInstead
. Doesn't that mean that my push should just update the remote master branch?
它允许推送到非裸仓库(see more here 关于 "push-to-deploy"),但错误消息与此无关。
它是关于您在本地没有的远程端的提交。
通常,您 pull --rebase
会在更新后的远程分支上重播您的更改。 然后你推。
我只是在学习Git
所以请多多包涵。我在本地编写了一些代码,现在我想将它推送到我的远程服务器 (origin
)。我收到此错误:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'ssh://website@host.website.com:2200/home/user'
Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing
遥控器是 v 2.4.1
并具有此设置(git config --list
的输出):
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
receive.denycurrentbranch=updateInstead
最后一个不是意味着我应该被允许在不引发错误的情况下覆盖冲突吗?
我基本上是在寻找最简单的设置:我不在服务器上开发,而且我是唯一可以访问它的人,所以我想要开发机器推动的任何东西。
我看到 this answer 关于使远程存储库裸露,但说明是删除文件夹中的所有内容,但 .git
。这对我不起作用,因为其中有些文件不属于我的项目,但我不想移动它们
如果我登录到远程存储库并执行 git status
我明白了
Untracked files: (use "git add ..." to include in what will be committed)
...(long list of files)
nothing added to commit but untracked files present (use "git add" to track)
附录
我刚刚做了:
$ git push --force origin master
stdin: is not a tty
Counting objects: 3801, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3674/3674), done.
Writing objects: 100% (3801/3801), 6.95 MiB | 37.00 KiB/s, done.
Total 3801 (delta 2450), reused 0 (delta 0)
error: Untracked working tree file 'cacert.pem' would be overwritten by merge.
To ssh://website@host.website.com:2200/home/user
! [remote rejected] master -> master (Could not update working tree to new HEAD)
error: failed to push some refs to 'ssh://website@host.website.com:2200/home/'
我想我可以删除该文件的服务器副本并重试吗?这两个文件具有相同的内容(这是一个 copy/paste 作业)
I don't want the local to import any change from the remote I want local files to overwrite remote files
问题是,如果您不想 git 拉取该错误消息,则需要:
git push --force
但这不仅会覆盖文件,还会覆盖您提交的远程端最近的提交历史记录,因此请确保这确实是您想要的。
the remote has setting
receive.denycurrentbranch=updateInstead
. Doesn't that mean that my push should just update the remote master branch?
它允许推送到非裸仓库(see more here 关于 "push-to-deploy"),但错误消息与此无关。
它是关于您在本地没有的远程端的提交。
通常,您 pull --rebase
会在更新后的远程分支上重播您的更改。 然后你推。