Git Tips

1 Submodule

$ git submodule add git-repos-url

Since the URL in the .gitmodules file is what other people will first try to clone/fetch from, make sure to use a URL that they can access if possible. For example, if you use a different URL to push to than others would to pull from, use the one that others have access to. You can overwrite this value locally with git config submodule..url PRIVATE_URL for your own use. When applicable, a relative URL can be helpful.

2 Make a git repository a bare repo

cd repo
mv .git ../repo.git # renaming just for clarity
cd ..
rm -fr repo
cd repo.git
git config --bool core.bare true

3 Fetch one branch from remote repository

$ git remote add -t remote-branch remote-name remote-url


© 2015-2020 tendant