如果我有一个空的存储库git init
,我想拉另一个存储库为只用于拉动更新我如何做到这一点,如果我想要的文件在根目录?Git克隆存储库到其他存储库的根?
所以,
让说:
cd ~/repositories
mkdir newrepo
cd newrepo
git init
echo "testfile" > readme.md
git add .
git remote add <whatever>
git push -u origin master
#ok so that part works fine
#now we have our repository at <my_other_repository> that looks like
#a_root_file.ext
#directory/another_file.ext
#so now I want to run something like:
git clone <my_other_repository>
#and end up with:
#readme.md
#a_root_file.ext
#directory/another_file.ext
#if I then run
echo "edited testfile" > readme.md
git status
#I want to be told that
#untracked changes
#newfile: a_root_file.ext
#newfile: directory/another_file.ext
#modified: readme.md
#running
git commit -a -m "Some files from another repository"
git push
#should push everything up to the <whatever> repository
#then I want to be able to run
git pull <my_other_repository_name>
# and have it pull in any upstream changes
这是不是可以设置吗?
我想我可以解决它稍微有“包装目录”
cd ~/repositories
mkdir newrepo
cd newrepo
git init
git remote add <whatever>
mkdir wrapper #this will now be the root of my project
cd wrapper
echo "testfile" > readme.md
cd ../
git add .
git push -u origin master
那么我应该能够运行git clone <my_other_repository>
没有问题,但是,如果我只是想在一个仓库合并只会工作,我想合并到几个存储库中,我也想知道跟踪这些更改会有什么结果,因为现在有两个存储库正在观察相同的文件,它们是否都会跟踪它们?或者<whatever>
会说“嘿,这些在这个存储库下,所以我们不会跟踪它!”?