将本地文件中的更新推送到 github 存储库时出错
Error in pushing updates in local files to github repository
我在本地对项目的某些 HTML 文件进行了一些更改,并尝试使用 Git Bash 将更改推送到我的 github 存储库。但是显示如下错误
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 integrate the remote changes
我更改了存储库形式 Github 的名称,但随后使用命令
在 Git Bash 上更新了它
git remote set-url origin https://github.com/cyborg7459/bambinos-task1
如何解决这个问题?
这里的问题是远程存储库正在更新其他用户的提交,这在您的本地不可用。因此,为了将本地更改推送到远程,您可以做的是首先将更改从上游拉到本地,解决合并冲突(如果有)并提交,然后最后推送。
Pull/get 来自上游的最新变化
git pull origin <branch>
推送更改
git push origin <branch>
备注
拉取后可能会出现一些合并冲突的情况,这时就得在本地解决了。暂存并提交更改。
git add .
git commit -m <commit message>
git push origin <branch>
我在本地对项目的某些 HTML 文件进行了一些更改,并尝试使用 Git Bash 将更改推送到我的 github 存储库。但是显示如下错误
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 integrate the remote changes
我更改了存储库形式 Github 的名称,但随后使用命令
在 Git Bash 上更新了它 git remote set-url origin https://github.com/cyborg7459/bambinos-task1
如何解决这个问题?
这里的问题是远程存储库正在更新其他用户的提交,这在您的本地不可用。因此,为了将本地更改推送到远程,您可以做的是首先将更改从上游拉到本地,解决合并冲突(如果有)并提交,然后最后推送。
Pull/get 来自上游的最新变化
git pull origin <branch>
推送更改
git push origin <branch>
备注 拉取后可能会出现一些合并冲突的情况,这时就得在本地解决了。暂存并提交更改。
git add .
git commit -m <commit message>
git push origin <branch>