I have a local project which is also present as a git repository.
Recently, me and my colleague worked on two different changes on the project. He modified some files and pushed it on the remote repository. I made some changes which are present in my local repository and do not conflict with any of his changes on the remote repository.
我需要首先从远程存储库中获取他的更改,然后将我的更改与我刚刚到达远程存储库的更改一起推送。我该怎么做?
像 - git pull origin master 这样的东西会用远程存储库上的当前项目覆盖我的本地更改吗?
有没有办法合并这些提交?
首先通过以下方式提交您的工作:
git add <path/to/file1>
git add <path/to/file2>
# ... etc. for each file
git commit -m 'commit message goes here'
Run Code Online (Sandbox Code Playgroud)
然后你可以通过合并来引入他的变化:
git pull origin master
git push origin master
Run Code Online (Sandbox Code Playgroud)
或者您可以在远程master分支上重新设置您的工作:
git pull --rebase origin master
git push origin master
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,只要您完成了工作,就不会丢失任何东西。master当您推送到远程存储库时,您的提交将位于本地分支的某个位置。
| 归档时间: |
|
| 查看次数: |
1580 次 |
| 最近记录: |