Working with Git repository with several remotes

I recently started playing with Kali's possibility of maintaining personal setup for Kali live distro. As I wanted to keep it versioned, I created a Git project for it in my repository. I wanted to accomplish the Git setup so that I can fetch the latest changes from the Kali repository at any time, which was easier said than done.


My research led me to the possibility of adding several remote repositories. The main one was of course my Git repository. The one I added was the Kali live build config one. As the Kali Git repository is not kept on the main Github repository but on a separate one owned by Kali, I didn't know how to easily fork the repository, short than doing some Git magic.


This is what I ended up with:



# Clone my empty fresh repository created on my Github account
git clone https://github.com/amohar/KaliLiveConfig.git
# Add the remote named "upstream" and check the naming
git remote add upstream git://git.kali.org/live-build-config.git
git remote -vv
# Fetch all
git fetch --all
# Perform the merge
git merge upstream/master --allow-unrelated-histories
# Push the code to my repository
git push


There are two paths that I could have chosen:



  • Rebase - This means the Kali commits would be pushed to the end of my project's history - hence rebased. This would also mean that my project would always have the unrelated histories as my initial commit would be the oldest one and wouldn't match with Kali's history. That is something I don't want as I'd have to rebase all the updates I make from Kali's repository

  • Allow unrelated histories - This is the one I wanted to take as the history would be merged correctly and my commits would end up at the end where they belong.


So far everything looks as working. If there are any Git professionals reading this post, I'd greatly appreciate any comments and feedback.

git