简体   繁体   English

如何拉入和推送远程 git 存储库

[英]How to pull and push in a remote git repository

I worked in a project on my desktop and pushed it in master branch.我在桌面上的一个项目中工作并将其推送到 master 分支。 Now i am working on my laptop with same project by downloading it in my laptop.现在我通过在我的笔记本电脑中下载它来使用相同的项目在我的笔记本电脑上工作。 After making some changes i want to marge this to my Github repository.进行一些更改后,我想将其添加到我的 Github 存储库中。 But says an error which is但是说一个错误是

error: failed to push some refs to ' https://github.com/mahfuz380/loginsystem ' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart.错误:无法将一些引用推送到“ https://github.com/mahfuz380/loginsystem ”提示:更新被拒绝,因为您当前分支的提示落后于提示:其远程副本。 Integrate the remote changes (eg hint: 'git pull ...') before pushing again.在再次推送之前集成远程更改(例如提示:'git pull ...')。 hint: See the 'Note about fast-forwards' in 'git push --help' for details.提示:有关详细信息,请参阅“git push --help”中的“关于快进的注意事项”。

Please follow the below steps when you try to push changes to remote branch.当您尝试将更改推送到远程分支时,请按照以下步骤操作。

  1. First save your local changes using git stash command首先使用 git stash 命令保存您的本地更改

    git stash
  2. Pull the changes from remote branch从远程分支拉取更改

    git pull
  3. Unstash your previously stash changes using below command使用以下命令取消您之前存储的更改

    git stash apply
  4. Push your changes to remote branch将您的更改推送到远程分支

    git push origin

If you encountered any conflicts once you unstash the changes then please resolve the conflicts manually and then push.如果您在取消隐藏更改后遇到任何冲突,请手动解决冲突,然后推送。

Hope it helps!希望能帮助到你!

git pull first before you push.在你推送之前先git pull You might have to undo your changes first.您可能必须先撤消更改。

As the message hinted, you should pull first to merge the changes, and push to remote.正如消息所暗示的那样,您应该先pull来合并更改,然后推送到远程。

git pull origin master
git push origin master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM