Reputation: 6741
I have a project that uses Git for version control.
It is based on an open source project, which is not managed with Git.
I start from a official release (say version 1.0) that I download from the project website (as a zip file).
In my repository, I add some files, modify others, delete some.
Then, the open source project releases a new version (say 2.0). I download the zip file and I want to synchronize it with my developments.
In this simple example, my development version of the software contains 3 files:
Content:
toto 1
toto 2
toto 3
Content:
line 1
line 2
line 30
The version 2.0 contains three files as well:
Content:
line 1
line 2
line 3
Content:
line 1
line 20
line 3
To merge my development version with the new release, I do the following:
git checkout -b v2.0
git add -A .
git commit -m "v2.0"
git checkout master
git merge v2.0
The console output is the following:
Updating 54cf5a5..14725f2
Fast-forward
modified.txt | 4 ++--
new_dev.txt | 3 ---
new_release.txt | 3 +++
3 files changed, 5 insertions(+), 5 deletions(-)
delete mode 100644 new_dev.txt
create mode 100644 new_release.txt
The problems are:
What did I do wrong?
Is there a better way to achieve this?
Upvotes: 1
Views: 74
Reputation: 521103
I would follow this workflow to cope with the remote project not being versioned by Git:
git init
git add
all project files, commit, and then git push origin master
git checkout -b yourBranch
to create a new branch from the original projectYou can now do all you work in yourBranch
as you would in any other feature branch. You can't contribute back to the remote project via Git, so you will presumably not be merging back to master
. When it is time to update your branch you can try the following
git checkout master
to switch to the master
branchgit add
for each file which has changed, followed by git commit
git checkout yourBranch
git merge master
This strategy should work, but it has one caveat. As time goes on you run the risk of diverging further and further from the remote project, which does not know of your changes. It could get to the point where bringing in the latest changes to master
and then merging could causs some ugly merge conflicts. The best long term solution might be to find a way to contribute to the remote project in both directions, either using Git or another versioning tool.
Upvotes: 2