推入子存储库也会影响父存储库为什么?

时间:2018-01-31 13:30:36

标签: git

我从ChildRepo分叉了一个存储库ParentRepo,然后我克隆了ChildRepo

ChildRepo/project_name > git checkout develop 
ChildRepo/project_name (develop) > git status //modified: README.md
ChildRepo/project_name (develop) > git remote -v //git@github.abc.com:cm/project_name.git
ChildRepo/project_name (develop) > git add .
ChildRepo/project_name (develop) > git commit -m "Style"
ChildRepo/project_name (develop) > git push

推入ChildRepo后,这些更改会反映在ParentRepoChildRepo中,我不知道为什么,请让我知道,因为我只想在{{1 }}

1 个答案:

答案 0 :(得分:1)

您应该检查从git remote -v获得的remote-url,它应该指向您自己的分叉存储库(子存储库),而不是父存储库。如果它指向父存储库,则使用

添加指向子存储库的新远程URL
git remote add upstream <child repo's remote-url>

然后,您可以使用

将更改推送到仅子存储库
git push <upstream/origin (whichever is pointing to child repo)> <Your branch name>