git checkout git_1
touch firstFile.txt
git add firstFile.txt
git commit -m "New file: firstFile.txt"
touch secondFile.txt
git add secondFile.txt
git commit -m "New fiel: secondFile.txt"
git checkout git_2
git merge git_1
git commit -a -m "Modified secondFile"
git commit -a -m "Edited secondFile"
git merge git_2 --no-ff
After resolving the conflict and leaving all 4 lines:
git commit -a -m "Resolved conflict"
git commit -a -m "Modified firstFile"
git commit -a -m "Edited firstFile"
Taking the hash of the commit to be transfered:
git log
Then we create the patch file:
Then we apply it in git_2:
git checkout git_2
git am 0001-Modified-firstFile.patch
Results:
First we need the hash of the commit:
Then we apply it in git_2:
For this purpose we will move HEAD pointer up by 2 commits using command:
git reset --soft "HEAD^^"
Soft mode ensures that all the changes remain. And then we make a new commit:
git commit -a -m "Concatinating the last two commits"
Result:
We will use git commit --amend command:
git reset --hard HEAD^^
Edited firstFile from folder2:
Edited firstFile from folder1:
Prepare for Step 20:
git stash
git pull origin git_1
This is how firstFile looks now:
Pushing:
Conflict while stashing:
Handling conflicts:
I'm going to leave only the stashed changes:
Result: