如何将工作目录与主目录同步,何时有人将更改推送到本地系统? [英] How to sync working directory with master directory, when somebody push change to our local system?

查看:124
本文介绍了如何将工作目录与主目录同步,何时有人将更改推送到本地系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

桌面1:

  mkdir gitrepo 
cd gitrepo
git init
git config - -bool core.bare true

笔记本电脑:

  git clone desktop@xxx.xxx.xxx.xxx:/ home / desktop 
cd gitrepo
vi readme
add readme
commit自述文件
git push

desktop1:我在这里看不到文件。



desktop2:我使用上述命令克隆到anoter第三个系统,我可以在第三个系统中看到该文件,但不是在我推送的存储库中。



因此,如何使用本地更改的文件更新destop1中的文件。

解决方案

您可以使用命令为:

  git checkout< file_name> 



如果您想与另一个分支中的文件同步,请使用以下命令:

  git checkout< branch_name> < FILE_NAME> 



如果要将任何分支与另一分支同步,请输入以下命令:

  git checkout< branch_name> 
git merge< branch_name>



示例:



假设我想更新master与分支br1,所以命令将是:

  git checkout master 
git merge br1


desktop1:

mkdir gitrepo
cd gitrepo
git init
git config --bool core.bare true

laptop:

git clone desktop@xxx.xxx.xxx.xxx:/home/desktop
cd gitrepo
vi readme
add readme
commit readme
git push

desktop1: I could not see the files here.

desktop2: I cloned to anoter 3rd system with the same as above command and I can see the file in 3rd system but not in the repository where I pushed.

So, how to update files in destop1 with the local changed files.

解决方案

You can sync up using the command as:

git checkout <file_name>

If you want to sync up with file in another branch give the command as:

git checkout <branch_name> <file_name>

If you want to sync any branch with another branch, give the command:

git checkout <branch_name>
git merge <branch_name>

Example:

Let's say I want to update master with branch br1, so command would be:

git checkout master
git merge br1

这篇关于如何将工作目录与主目录同步,何时有人将更改推送到本地系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆