Merging Repositories in to a single repository
In order to merge repositories into a single repo with
- Each project in their own directory
- The whole history maintained for them
- No use of rebase and other dangerous/complicated features of git
Do the following:
- Pick the repo everything is being merged into (Repo A).
- Go to a repo you want to merge into Repo A (Repo B).
- [B] Pick the name of the subdirectory you’d like Repo B to be in when in Repo A and create that folder (e.g.
- [B] Move everything into that folder using git:
git mv !(repo_b) repo_b
- [B] Commit that in Repo B.
- [A] In Repo A add a remote to Repo B’s full folder path:
git remote add repo_b /home/me/projects/project_b
- [A] Merge Repo B in to Repo A:
git merge -S --allow-unrelated-histories repo_b/master
- [A] Remove the remote:
git remote rm repo_b
Repeat starting at step 2 until all the repos are merged in to Repo A.
Super useful in git to take advantage of advanced features without typing so much each time.
Not the same thing as bash aliases, although some of these could be easily implemented as zsh/bash aliases or functions.
To add aliases go to your
$HOME folder and edit or create
.gitconfig. Update it like below with some example aliases I’ve picked up.
[alias] lol1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all lol = log --oneline --graph --color --all --decorate
For inspiration on aliases look at other’s dotfiles on github. I took a lot of inspriation from @jessfraz’s