How do you merge two Git repositories?

If you want to merge project-a into project-b: cd path/to/project-b git remote add project-a /path/to/project-a git fetch project-a –tags git merge –allow-unrelated-histories project-a/master # or whichever branch you want to merge git remote remove project-a Taken from: git merge different repositories? This method worked pretty well for me, it’s shorter and in my opinion a … Read more

How do I clone a Git repository into a specific folder?

Option A: git clone git@github.com:whatever folder-name Ergo, for right here use: git clone git@github.com:whatever . Option B: Move the .git folder, too. Note that the .git folder is hidden in most graphical file explorers, so be sure to show hidden files. mv /where/it/is/right/now/* /where/I/want/it/ mv /where/it/is/right/now/.* /where/I/want/it/ The first line grabs all normal files, the … Read more

Remove a file from a Git repository without deleting it from the local filesystem

The git rm documentation states: When –cached is given, the staged content has to match either the tip of the branch or the file on disk, allowing the file to be removed from just the index. So, for a single file: git rm –cached file_to_remove.txt and for a single directory: git rm –cached -r directory_to_remove