It's good to get in the habit of putting everything into a git repo, and that means having a canonical remote for experiments. Creating remotes for each experiment becomes a clutter of keys and repos. So it's best to merge all of those experiments into a larger experiments repo and just push that repo to github.
Instead of thousands of repos, consolidate your configs and experiments into a single repo on your development machine like so:
In this case I needed a simple main.c
to test ARM support for NEON (like SSE on intel) on Raspberry PI. The directory was primitive, but I still wanted to retain the experiment:
- arm_neon/
- main.c
- .gitignore
To preserve this repo, I still use git init and manage commits within arm_neon locally, but "subtree" it into an experiments repo using git subtree add
. Here are the steps.
1. Initialize and Commit the Experiment locally on Raspberry Pi
cd arm_neon
git init
git add -u
git commit -m "arm register test working"
2. Add the arm_neon Experiment Remote
On the development machine , add the arm_neon experiment as a remote within the experiments repo.
cd experiments
git remote add arm_neon ssh://pi@pi4.local/home/pi/test/arm_neon
git fetch arm_neon
# git warns you the two repos have nothing in common-- as expected
warning: no common commits
Add the subtree using arm_neon as the prefix (the directory)
PREFIX=arm_neon
REMOTE=arm_neon
git subtree add -P $PREFIX $REMOTE master
Test that it worked
git log -1
93dc44e - (tag: arm_neon_latest, tonymet/master) Add 'arm_neon/' from commit '083a748c92a4b04caa667c3573de4fb0c46c86fc' (33 minutes ago) <Anthony Metzidis>
3. Push the Experiments to Github
Now experiments contains arm_neon and hundreds of others. Push it up to github.
git push github HEAD
4. Continue Experimentation & Tracking Changes
Now that the two repos are linked, you can continue making changes to arm_neon and use git subtree merge to incorporate the latest commits.
# on raspberry pi, a new commit has been made
git log
3d7315a - (HEAD -> master) improve docs (11 seconds ago) <Anthony Metzidis>
083a748 - arm neon call (26 minutes ago) <Anthony Metzidis>
now merge those changes into the experiments repo
# get latest changes on development machine
git fetch arm_neon
# merge those into the subtree .
git subtree merge arm_neon/master -P arm_neon
Now the experiments repo contains all the latest changes from arm_neon, and can be pushed to github.
git log -1
93dc44e - (HEAD -> master) Add 'arm_neon/' from commit '083a748c92a4b04caa667c3573de4fb0c46c86fc' (5 seconds ago) <Anthony Metzidis>
Now you have one repo that contains hundreds of experiments , rather than creating hundreds of repos in your github account.
Top comments (0)