working with git for the first time and encountered a problem with merging. the work flow was something as follows:
created repository on gitlab and each member linked locally
- added two text files to master branch - recipe_book.txt and ingredients.txt
- edited the two file and they were added, committed and pushed
- created two branches from master - vegetarian and pizza-pasta
- in pizza-pasta branch both files were re-written (not just slightly modified), added committed and pushed.
- in vegetarian branch both files were re-written (not just slightly modified), added committed and pushed.
- on master - master and pizza-pasta were merged this resulted in a fast-forward merge (as suggested below) -reverted to commit pre-merge -tried no fast-forwarding merge however only parts of the content of files in pizza-pasta were added to the content of the files in master.
the aim of this task is to two files in three different branches (files must retain same name however content must be completely different) in the end all the branches must be merged so that the files in the master branch contain the content that was originally in each of the three branches.
summary of commands used (editing of files was done manually and locally by each participant):
git add ingredients.txt
git commit -m "adding blank file ingredients.txt"
git add recipe_book.txt
git commit -m "adding blank file recipe_book.txt"
git push -u origin master
git add ingredients.txt
git commit -m "updating file ingredients.txt with content"
git add recipe_book.txt
git commit -m "updating file recipe_book.txt with content"
git push -u origin master
git branch vegetarian
git push origin vegetarian
git branch pizza-pasta
git push origin pizza-pasta
git checkout vegetarian
git add ingredients.txt
git commit -m "updating file ingredients.txt with completely new content"
git add recipe_book.txt
git commit -m "updating file recipe_book.txt with completely new content"
git push -u origin vegetarian
git checkout pizza-pasta
git add ingredients.txt
git commit -m "updating file ingredients.txt with completely new content"
git add recipe_book.txt
git commit -m "updating file recipe_book.txt with completely new content"
git push -u origin pizza-pasta
git checkout master
git merge master pizza-pasta \\ here i made the fast-forward merge mistake
git reset --hard fe6fff
git reset --soft HEAD@{1}
git commit -m "reverting to pre-merge"
git push -u origin master
git merge --no-ff master pizza-pasta \\ here i made the merge with no fast-forward