简体   繁体   中英

Combining multiple git repos under one repo

I recently finished a class for which I have three assignment GitHub repos, two originally created by forking the class's repos and one is hosted by a classmate (group project). I want to consolidate my code in my local repos under one remote-&-local repo with the class name, preferably while keeping the commit and branch history, and removing my two remote repos, and disconnecting the group project's remote repo from my local group project repo. I created a local directory named it the class name, copy-pasted the three local assignment repos into it, ran git init , in the class-name repo and then ran git remote rm origin in the root of each assignment repo. I foolishly deleted my two remote assignment repos, and now I suspect the steps found here won't work for those two, specifically step 3:

# Add a remote for and fetch the old repo
# (the '--fetch' (or '-f') option will make git immediately fetch commits to the local repo after adding the remote)
git remote add --fetch old_a <OldA repo URL>

Is there a way to rely on local commit history? Or could this step could be skipped entirely?

The more I read that powershell script the more I think it's not quite what I want to do. It seems more appropriate for combining code from other repos into an existing repo rather than creating one repo with multiple former-repos inside it; am I wrong?

If you still have the local history for your assignments, you are still good.

Any repo can serve as remote, even a local one -- the "url" is simply the path to that repo:

git remote add ex1 ../../exercise1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM