Force a Git Conflict [duplicate]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1
















This question already has an answer here:




  • Producing a git merge conflict

    1 answer



  • Simulating Conflict in GIT

    1 answer




For my Job I make an Introduction Presentation about Git.
I want to show how to resolve merge conflicts. But to do so I need to get a merge conflict. For demonstration purposes I wrote a simple HTML Document in this Document is a Table were the Participants enter there Name. Will this be enough to generate a conflict?










share|improve this question













marked as duplicate by Liam, mkasberg, Antwane, j08691, phd Nov 16 '18 at 20:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    Make 2 branches edit the same file in the same place in each branch, try and merge one into the other. simple

    – Liam
    Nov 16 '18 at 16:33











  • stackoverflow.com/search?q=%5Bgit%5D+produce+merge+conflict

    – phd
    Nov 16 '18 at 20:12


















1
















This question already has an answer here:




  • Producing a git merge conflict

    1 answer



  • Simulating Conflict in GIT

    1 answer




For my Job I make an Introduction Presentation about Git.
I want to show how to resolve merge conflicts. But to do so I need to get a merge conflict. For demonstration purposes I wrote a simple HTML Document in this Document is a Table were the Participants enter there Name. Will this be enough to generate a conflict?










share|improve this question













marked as duplicate by Liam, mkasberg, Antwane, j08691, phd Nov 16 '18 at 20:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    Make 2 branches edit the same file in the same place in each branch, try and merge one into the other. simple

    – Liam
    Nov 16 '18 at 16:33











  • stackoverflow.com/search?q=%5Bgit%5D+produce+merge+conflict

    – phd
    Nov 16 '18 at 20:12














1












1








1


0







This question already has an answer here:




  • Producing a git merge conflict

    1 answer



  • Simulating Conflict in GIT

    1 answer




For my Job I make an Introduction Presentation about Git.
I want to show how to resolve merge conflicts. But to do so I need to get a merge conflict. For demonstration purposes I wrote a simple HTML Document in this Document is a Table were the Participants enter there Name. Will this be enough to generate a conflict?










share|improve this question















This question already has an answer here:




  • Producing a git merge conflict

    1 answer



  • Simulating Conflict in GIT

    1 answer




For my Job I make an Introduction Presentation about Git.
I want to show how to resolve merge conflicts. But to do so I need to get a merge conflict. For demonstration purposes I wrote a simple HTML Document in this Document is a Table were the Participants enter there Name. Will this be enough to generate a conflict?





This question already has an answer here:




  • Producing a git merge conflict

    1 answer



  • Simulating Conflict in GIT

    1 answer








git git-merge






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 16:31









LimatuzLimatuz

122229




122229




marked as duplicate by Liam, mkasberg, Antwane, j08691, phd Nov 16 '18 at 20:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Liam, mkasberg, Antwane, j08691, phd Nov 16 '18 at 20:12


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2





    Make 2 branches edit the same file in the same place in each branch, try and merge one into the other. simple

    – Liam
    Nov 16 '18 at 16:33











  • stackoverflow.com/search?q=%5Bgit%5D+produce+merge+conflict

    – phd
    Nov 16 '18 at 20:12














  • 2





    Make 2 branches edit the same file in the same place in each branch, try and merge one into the other. simple

    – Liam
    Nov 16 '18 at 16:33











  • stackoverflow.com/search?q=%5Bgit%5D+produce+merge+conflict

    – phd
    Nov 16 '18 at 20:12








2




2





Make 2 branches edit the same file in the same place in each branch, try and merge one into the other. simple

– Liam
Nov 16 '18 at 16:33





Make 2 branches edit the same file in the same place in each branch, try and merge one into the other. simple

– Liam
Nov 16 '18 at 16:33













stackoverflow.com/search?q=%5Bgit%5D+produce+merge+conflict

– phd
Nov 16 '18 at 20:12





stackoverflow.com/search?q=%5Bgit%5D+produce+merge+conflict

– phd
Nov 16 '18 at 20:12












3 Answers
3






active

oldest

votes


















2














Here is how to generate conflict



# init your repo
git init

# print some text to any given file
echo 'aaa' > a.txt

# commit to the current branch
git add a.txt && git commit -m "Commit1"

# create a new branch
git checkout -b branch1

# add code to the end of the file
echo 'bbb' >> a.txt

# commit to the current branch (b)
git add a.txt && git commit -m "Commit2"

# get back to master branch
git checkout master

# add code to the end of the file
# here the file will still have its original code
echo 'ccc' >> a.txt

# commit to the current branch (master)
git add a.txt && git commit -m "Commit3"

# now when you will try to merge you will have conflict
git merge b





share|improve this answer

































    3














    Interesting question :)



    Create a new branch with git checkout -b new-branch, edit a line, make a commit.



    Switch to the original branch, edit the same line with a different edits, make another commit.



    Now git merge new-branch, and you'll a get a merge conflict! :)






    share|improve this answer































      2














      There are many kinds of conflicts you can produce. Normally people think of modifying some lines in different ways on separate branches... that's fine. That's one type of conflict. But there are others.




      • Take a pice of code (some lines from a file) and delete them. Take another branch and modify them. Then merge.


      • Take a file and remove it. Then go to another branch and edit it. Then merge.


      • Take a file and rename it. Then go to another branch and rename it some other way. Then merge.







      share|improve this answer






























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        2














        Here is how to generate conflict



        # init your repo
        git init

        # print some text to any given file
        echo 'aaa' > a.txt

        # commit to the current branch
        git add a.txt && git commit -m "Commit1"

        # create a new branch
        git checkout -b branch1

        # add code to the end of the file
        echo 'bbb' >> a.txt

        # commit to the current branch (b)
        git add a.txt && git commit -m "Commit2"

        # get back to master branch
        git checkout master

        # add code to the end of the file
        # here the file will still have its original code
        echo 'ccc' >> a.txt

        # commit to the current branch (master)
        git add a.txt && git commit -m "Commit3"

        # now when you will try to merge you will have conflict
        git merge b





        share|improve this answer






























          2














          Here is how to generate conflict



          # init your repo
          git init

          # print some text to any given file
          echo 'aaa' > a.txt

          # commit to the current branch
          git add a.txt && git commit -m "Commit1"

          # create a new branch
          git checkout -b branch1

          # add code to the end of the file
          echo 'bbb' >> a.txt

          # commit to the current branch (b)
          git add a.txt && git commit -m "Commit2"

          # get back to master branch
          git checkout master

          # add code to the end of the file
          # here the file will still have its original code
          echo 'ccc' >> a.txt

          # commit to the current branch (master)
          git add a.txt && git commit -m "Commit3"

          # now when you will try to merge you will have conflict
          git merge b





          share|improve this answer




























            2












            2








            2







            Here is how to generate conflict



            # init your repo
            git init

            # print some text to any given file
            echo 'aaa' > a.txt

            # commit to the current branch
            git add a.txt && git commit -m "Commit1"

            # create a new branch
            git checkout -b branch1

            # add code to the end of the file
            echo 'bbb' >> a.txt

            # commit to the current branch (b)
            git add a.txt && git commit -m "Commit2"

            # get back to master branch
            git checkout master

            # add code to the end of the file
            # here the file will still have its original code
            echo 'ccc' >> a.txt

            # commit to the current branch (master)
            git add a.txt && git commit -m "Commit3"

            # now when you will try to merge you will have conflict
            git merge b





            share|improve this answer















            Here is how to generate conflict



            # init your repo
            git init

            # print some text to any given file
            echo 'aaa' > a.txt

            # commit to the current branch
            git add a.txt && git commit -m "Commit1"

            # create a new branch
            git checkout -b branch1

            # add code to the end of the file
            echo 'bbb' >> a.txt

            # commit to the current branch (b)
            git add a.txt && git commit -m "Commit2"

            # get back to master branch
            git checkout master

            # add code to the end of the file
            # here the file will still have its original code
            echo 'ccc' >> a.txt

            # commit to the current branch (master)
            git add a.txt && git commit -m "Commit3"

            # now when you will try to merge you will have conflict
            git merge b






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 16 '18 at 17:08

























            answered Nov 16 '18 at 17:05









            CodeWizardCodeWizard

            55.8k1271100




            55.8k1271100

























                3














                Interesting question :)



                Create a new branch with git checkout -b new-branch, edit a line, make a commit.



                Switch to the original branch, edit the same line with a different edits, make another commit.



                Now git merge new-branch, and you'll a get a merge conflict! :)






                share|improve this answer




























                  3














                  Interesting question :)



                  Create a new branch with git checkout -b new-branch, edit a line, make a commit.



                  Switch to the original branch, edit the same line with a different edits, make another commit.



                  Now git merge new-branch, and you'll a get a merge conflict! :)






                  share|improve this answer


























                    3












                    3








                    3







                    Interesting question :)



                    Create a new branch with git checkout -b new-branch, edit a line, make a commit.



                    Switch to the original branch, edit the same line with a different edits, make another commit.



                    Now git merge new-branch, and you'll a get a merge conflict! :)






                    share|improve this answer













                    Interesting question :)



                    Create a new branch with git checkout -b new-branch, edit a line, make a commit.



                    Switch to the original branch, edit the same line with a different edits, make another commit.



                    Now git merge new-branch, and you'll a get a merge conflict! :)







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 16 '18 at 16:38









                    kopirokopiro

                    519210




                    519210























                        2














                        There are many kinds of conflicts you can produce. Normally people think of modifying some lines in different ways on separate branches... that's fine. That's one type of conflict. But there are others.




                        • Take a pice of code (some lines from a file) and delete them. Take another branch and modify them. Then merge.


                        • Take a file and remove it. Then go to another branch and edit it. Then merge.


                        • Take a file and rename it. Then go to another branch and rename it some other way. Then merge.







                        share|improve this answer




























                          2














                          There are many kinds of conflicts you can produce. Normally people think of modifying some lines in different ways on separate branches... that's fine. That's one type of conflict. But there are others.




                          • Take a pice of code (some lines from a file) and delete them. Take another branch and modify them. Then merge.


                          • Take a file and remove it. Then go to another branch and edit it. Then merge.


                          • Take a file and rename it. Then go to another branch and rename it some other way. Then merge.







                          share|improve this answer


























                            2












                            2








                            2







                            There are many kinds of conflicts you can produce. Normally people think of modifying some lines in different ways on separate branches... that's fine. That's one type of conflict. But there are others.




                            • Take a pice of code (some lines from a file) and delete them. Take another branch and modify them. Then merge.


                            • Take a file and remove it. Then go to another branch and edit it. Then merge.


                            • Take a file and rename it. Then go to another branch and rename it some other way. Then merge.







                            share|improve this answer













                            There are many kinds of conflicts you can produce. Normally people think of modifying some lines in different ways on separate branches... that's fine. That's one type of conflict. But there are others.




                            • Take a pice of code (some lines from a file) and delete them. Take another branch and modify them. Then merge.


                            • Take a file and remove it. Then go to another branch and edit it. Then merge.


                            • Take a file and rename it. Then go to another branch and rename it some other way. Then merge.








                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 16 '18 at 17:04









                            eftshift0eftshift0

                            5,9221022




                            5,9221022















                                Popular posts from this blog

                                The Sandy Post

                                Danny Elfman

                                Pages that link to "Head v. Amoskeag Manufacturing Co."