Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git如何在具有相同存储库的两个不同文件夹之间同步_Git - Fatal编程技术网

git如何在具有相同存储库的两个不同文件夹之间同步

git如何在具有相同存储库的两个不同文件夹之间同步,git,Git,如上图所示,每个节点都表示提交 在C节点创建存储库,然后将此存储库克隆到两个不同的文件夹folderA/folderB 在folderA出于某种原因回滚C节点并执行某些操作,将其向前更改为D节点,然后按遥控 然后我想要floderB同步到远程,然后运行git pull命令,它将自动合并 folderA日志历史记录 * dd0b2ef add file * d795c47 first init * 2d7dd9d Merge branch 'master' of http://.../git

如上图所示,每个节点都表示提交

C
节点创建存储库,然后将此存储库克隆到两个不同的文件夹
folderA/folderB

folderA
出于某种原因回滚
C
节点并执行某些操作,将其向前更改为
D
节点,然后按遥控

然后我想要
floderB
同步到远程,然后运行
git pull
命令,它将自动合并

folderA
日志历史记录

* dd0b2ef add file
* d795c47 first init
*   2d7dd9d Merge branch 'master' of http://.../git-test
|\
| * dd0b2ef add file
* | 186db65 second commit
|/
* d795c47 first init
folderB
日志历史记录

* dd0b2ef add file
* d795c47 first init
*   2d7dd9d Merge branch 'master' of http://.../git-test
|\
| * dd0b2ef add file
* | 186db65 second commit
|/
* d795c47 first init

如何让
folderB
也自动回滚到
B
而不合并如果我正确理解了您的问题,您希望
folderB
准确跟踪
原点发生的情况。在这种情况下,您可以使用

git fetch origin                 # Get updates from origin (but don't apply them)
git reset --hard origin/master   # Reset the working tree to match origin/master
git clean -fd                    # Remove all untracked files, so we match origin/master exactly

git reset B--hard
@ElpieKay是的,但是如何让程序自动执行此操作,请检查存储库是否有回滚操作,然后运行
git reset
rollback和
git pull
同步存储库。每当存储库没有回滚操作时,只要运行
git pull
,如果有,我们需要人为干预
git fetch origin master&&git checkout fetch\u HEAD