If I have an empty repository git init and I want to pull in another repository to be used only for pulling in updates how can I do this if I want the files to be in the root directory?
So,
lets say:
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
Is this something it is possible to setup?
I imagine I could work around it slightly by having a “wrapper directory”
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
I should then be able to run git clone <my_other_repository> without issue but this will only work if I only want to merge in one repository, and I am wanting to merge in several repositories and I also wonder what would be tracking the changes since there are now two repositories watching the same files, would both track them? or would <whatever> say “hey these are under this repository, so we won’t track it!”?
I’m not quite sure exactly what you’re asking for here, but you should be aware that you can have more than one
remote. For example, you could:Then, you can pull in updates using
git fetch another. You can then merge in updates using:to merge updates from your other repository into your local repository.