Anonymous user
Open Source Comes to Campus/Curriculum/Git/Students: Difference between revisions
Open Source Comes to Campus/Curriculum/Git/Students (view source)
Revision as of 18:41, 23 November 2013
, 10 years ago→Resolving Merge Conflicts
imported>Shauna No edit summary |
imported>Shauna |
||
Line 134:
Your instructor should have showed you what she sees when you submit a pull request. Probably you saw a message from Github saying that the pull request could be "merged automatically". That means that you managed to avoid changing a part of the project that someone else also changed. Yay! That's how we designed this activity. But what happens if you ''do'' change the same part of a project as someone else? It generates what we call a "merge conflict".
(A brief thought experiment to explain merge conflicts: let's say there's a repository with a single file that says, '''Hello [celestial object]!''' If you change that to '''Hello world!''' and submit a pull request, you're creating a diff which says: ''change "[celestial object]" to "world"''. If someone else copied the repository at the same time as you and changed the same line, they might create a diff which says ''change "[celestial object]" to "galaxy"''. If you make your changes to the repository first, it now says '''Hello world!''', so when the other person says '''change "[celestial object]" to "galaxy"''' the repository does not see [celestial object] and says, "There's a conflict here.")
To induce a merge conflict in this activity, go to the main github repository and find a change that has been made since the last time you copied the repository (
▲To induce a merge conflict in this activity, go to the main github repository and find a change that has been made since the last time you copied the repository (this may well be when you did "git clone"). Make a change, locally, to the same line. Then type:
git fetch [url of main project]
|