Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Third party project not in GIT - New version - Keep my changes

Tags:

git

conflict

I have bought (licenced) some code from Codecanyon that is not maintained in GIT. I have now made quite a few changes to it (using GIT). Pretty soon the authors of the original code will release a new version. I will want to incorporate their changes without losing my own. I would therefore like to load their code and get GIT to point out conflicts so that I may be able to (hopefully) incorporate the new code into mine. Can anyone recommend a safe way of achieving this please? Thanks.

like image 344
user9245539 Avatar asked Mar 02 '26 18:03

user9245539


2 Answers

If you have, in your local repo, a commit with the first version of their code :

$ git log --graph --oneline
1234ee * (HEAD -> master) my latest changes 
1234dd * added a feature
  ...
1234aa * a commit, with the initial version of the product's code
  ...

You can :

  • create a branch that starts on that commit :
git checkout -b upstream 1234aa
  • update the code with the new version :
# to be thorough : you should delete files which existed in the first version,
# and do not exist in the new version
git rm -- [list all files of original archive]

# for example, here is one way to drop all versioned files :
git rm -- "*"

# extract the files from the new version :
tar -xzf newversion.tgz

# add and commit :
git add .
git commit -m "new version"
  • you can now merge upstream in your local branch :
git checkout master
git merge upstream
like image 177
LeGEC Avatar answered Mar 04 '26 11:03

LeGEC


It's not so good to mix git with non-git projects and maybe this is opinion based, but this is what I would do:

  1. Create a git repo, put your 3rd party code in it and do your first commit (this will be your masteror main branch as you whish to call it.
  2. Create a new branch next (you choose tha name)
  3. Do your modifications on this branch, commit them regularly and merge them to master when they work properly.
  4. When your 3rd party project has a new release, make sure all your modifications are in your master, then create a branch thirdParty and replace its content with the new release (this is where it gets ugly).
  5. Commit this change.
  6. Then you have two options a) Merge thirdParty with master or b) master with thirdParty. This can be very messy taking in count that their modifications must be huge, so I'd choose b).
  7. Git will print all the conflicts and you will solve them :)
like image 31
Ivan Avatar answered Mar 04 '26 11:03

Ivan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!