I have a big Git
repository for a project for which I created a plug-in which also is source controller with Git
. Recently I copied the plug-in's folder to the main project folder. Now I have a project folder source controlled with Git
and the plug-in's folder which is also source controlled with Git
. My question is, is there a way to import the commits from the plug-in's repository to the main repository so I can get rid of the plug-in's .git
folder?
Yes. You can place your LICENSE commit as the first commit by rebasing. Rebasing is gits way of rearranging commit order while keeping all the commit authors and commit dates intact. When working on a shared repo, it's generally discouraged unless your entire team is git-fluent.
It is possible to cherry pick from another repo using the command line. You will first need to add the other repository as a remote and then fetch the changes. From there, you should be able to see the commit in your repo and cherry pick it.
We will use git cherry-pick , which is a git command to get commits from another branch or repository. In order to get commits from the other repository, You'll need to add the other repository as a remote, then fetch its changes. From there you see the commit and you can cherry-pick it.
To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.
Open a command window in the project folder.
Make sure you're on a branch. e.g. git checkout -b plugin-history
Add the plugin folder as a remote: git remote add plugin ../path/to/plugin/repo
Fetch the hashes from the new remote: git fetch plugin
Bulk cherry-pick all the plugin history from the remote branch:
git cherry-pick firstSha1^..mostRecentSha1
(There are more instructions about cherry-picking multiple commits here: How to cherry-pick multiple commits)
You should then have all the history as new commits on the plugin-history branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With