Can't combine Version2 with Version1 in Git
I have two files called
- version1
- version2
Version 1 has its own changes, and version2 has version 1, but it has other changes as well.
I run the following command in my Git folder where Version1 is
git add version2
I now have two separate files in Git. Now I would like to combine them.
What command should I run to only have version2 and history of version1?
a source to share
The best way to achieve what you describe is to go in and change version 1 with all their changes and run
git commit -a -m "incorporated others changes into Version1"
Thus, Git will track those changes and create two versions of version 1, which is the original and the other with the changes.
If you want more splitting than that, I would create a branch, since branches are so easy to do in Git.
You can create master or raw branch where you save the originals and then save your changes.
it will look something like this.
$> mkdir src
$> cd src && git init .
$> touch Version1 && touch Version2
$> git add . && git commit -a -m "initial commit"
$> git checkout -b changes # this creates a branch called changes
# Make changes to the files
$> git commit -a -m "made some changes"
$> git checkout -b master # back to your master branch.
Hope it helps.
a source to share