PDA

View Full Version : How best to merge changes from two semi forked copies of a project...



KurtEck
06-25-2015, 04:14 PM
Suppose, maybe a year and a half ago, I made my own fork of a project (Not an actual fork, but different project name...)

Suppose that there have been several updates to the original project. I am trying to figure out how I want to merge the changes. I can think of a few different approaches, including:

Use a simple diff tool, like winmerge and try to migrate all of the changes from the original project into mine. Obviously this can be error prone...

See if I can get a set of sources that is an ancestor of both, and maybe use a better merge program, maybe meld on my Linux box... May be better, but obviously it would not show any of the history of changes... I could also do it in reverse and simply add this as a new branch of my fork of the original project... In this way would not lose original projects history, but would lose my older history, which is probably not important...

Somehow use git to create a set of patch files, that I can somehow try to imply?

Other approaches?

Thanks

Kurt

P.S. - The actual projects involved is my version of USB2AX with Pypose capabilities back to the original USB2AX.

jwatte
06-25-2015, 05:01 PM
Wholesale copying is more powerful than you might think :-)

Assuming there was a version you copied at time X.

Install msysgit on Windows.
Create a new Git repo in an empty folder.

mkdir folder
cd folder
git init .

Copy the sources from version X recursively into this folder.

xcopy /s/e/h/i/c/r/y C:\source\folder

Add and commit:

git add .
git commit -m "first"

Now, create a Git branch, and check that out:

git branch mystuff
git checkout mystuff

Now, delete all files except the .git directory!

rm -rf *

Copy the sources of your latest version in here.

xcopy /s/e/h/i/c/r/y C:\your\new\stuff

(Make sure the directories are at the same level as the "source")
Add all your changes:

git add -f *
git commit -m "my stuff"

Now, go back to the master branch:

git checkout master

And update to the latest version of the software you're based off:

rm -rf *
xcopy /s/e/h/i/c/r/y C:\path\to\latest
git add -f *
git commit -m "latest"

OK, now you have a git repo with the evolution from point A to the latest, as well as point A to your stuff.
Now, you can merge either from master into your branch, or from your branch to master, using regular git history.
Then, in the future, you probably want to keep this git repo around. Perhaps push the repo to some server somewhere, create a "remote" for the "upstream" and occasionally pull into it, etc.

KurtEck
06-25-2015, 05:13 PM
Thanks Jwatte,

May have to try this, instead of doing it all manual...

Currently I have git for windows installed, But wonder if the msysgit is better. May have to give it a try...

Thanks again!

jwatte
06-26-2015, 11:24 AM
Currently I have git for windows installed, But wonder if the msysgit is better.

I like msysgit because I like the UNIX-style commands (even inside COMMAND.COM windows.)
If you can run the same commands using Windows Git, that'll work fine.
Or do it all on a Linux box / Raspberry Pi :-)