如果我有一个空存储库git init
,并且我想拉入另一个存储库以仅用于拉入更新,如果我希望文件位于根目录中,我该怎么做?
所以,
让我们说:
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>
说“嘿,这些都在这个存储库下,所以我们不会跟踪它!”?