Changes

Jump to: navigation, search

DPS909 & OSD600 Winter 2017 - Lab 4

13,447 bytes added, 15:11, 24 November 2017
Submission
bird of paradise
Now let's merge our <code>water-animals</code> branch into <code>animals</code>:
# Switch to your <code>animals</code> branch
# Merge <code>water-animals</code> into <code>animals</code> (i.e., <code>git merge water-animals</code>)
# Confirm that your <code>animals</code> branch now contains the changes you made to <code>animals.txt</code>
Because our <code>water-animals</code> branch was ahead of our <code>animals</code> branch by 1 commit, git was able to do this merge using the '''fast-forward''' merge algorithm, which simply moves the branch ahead to align with the other branch. If you use <code>git log</code> you'll notice that there is no '''merge commit''' this time.
Next, let's merge our <code>jungle-animals</code> branch into <code>animals</code> as well. Since both of these branches touch the same lines of the same file, this won't work automatically, and we'll have to fix it manually:
After # Switch to your <code>animals</code> branch# Merge <code>jungle-animals</code> into <code>animals</code> (i.e., <code>git merge jungle-animals</code>) Git will respond and indicate that there was an issue merging <code>animals.txt</code>:  Auto-merging animals.txt CONFLICT (content): Merge conflict in animals.txt Automatic merge failed; fix conflicts and then commit the result. Let's fix the merge conflict. Confirm that we are mid-way through a merge and have a merge conflict using <code>git status</code>. You'll see something like this:  On branch animals You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) Unmerged paths: (use "git add <file>..." to mark resolution) both modified: animals.txt no changes added to commit (use "git add" and/or "git commit -a") Open the <code>animals.txt</code> file. Here is what mine looks like:  horse cow chicken <<<<<<< HEAD whale seahorse dolphin ======= monkey python bird of paradise >>>>>>> jungle-animals Notice the presence of <code><<<<<<< HEAD</code>, <code>=======</code>, and <code>>>>>>>> jungle-animals</code>. These are '''conflict markers''' and show the different versions of the lines in question. Because we are merging ''into'' <code>animals</code>, it is our <code>HEAD</code>, and everything between <code><<<<<<< HEAD</code> and <code>=======</code> is what is on this branch. Everything between <code>=======</code> and <code>>>>>>>> jungle-animals</code> is what is on the <code>jungle-animals</code> branch. Because both branches edit the '''same lines of the same file''', git needs us to resolve the conflict. We have a few options: * Use what is in <code>HEAD</code>, and erase the lines from <code>jungle-animals</code>* Do the opposite and use what is in <code>jungle-animals</code>, and erase what is in <code>HEAD</code>* Combine the two sets of changes into one change In this case, we just need to combine the entries into a single, longer list. He can simply remove the conflict markers and save the file. Here's what mine looks like when I'm done:  horse cow chicken whale seahorse dolphin monkey python bird of paradise Now we can <code>add</code> and <code>commit</code> this conflict resolution in order to finish our merge. When we're done, we'll have a new '''merge commit''' that combines the changes from our two branches into <code>animals</code>. ==5. Rebasing, Squashing== At this point our <code>animals</code> branch is where we want it, in terms of content; but it's a bit messy in terms of how we got there. Sometimes before we share (i.e., <code>git push</code>) branches to share with colleagues, we want to clean up our history. Wouldn't it be nice if we could take all the different commits we made, and combine them into a single commit that achieved the same result? We can, and it's called a '''rebase'''. First, a few warnings. Unlike a merge, which always keeps your history intact, a rebase will alter your commit history. You should never do this to a branch that has been shared with other developers, since it will erase and re-create commits, which makes it impossible for others to collaborate with you on those commits. A rebase is only something you should do '''before''' youshare your commits with others. Let've picked s practice a rebase on our <code>animals</code> branch, and '''squash''' our separate commits into one single commit: # Switch to your <code>animals</code> branch# Start an '''interactive rebase''': <code>git rebase -i master</code> This will open your editor and show you all of the commits on <code>animals</code> that are ahead of <code>master</code>. Mine looks like this: <pre>pick 436a838 Adding animals.txtpick 595f37e Added water animalspick 3d7af87 Add jungle animals # Rebase 21826a9..3b4d451 onto 21826a9 (3 commands)## Commands:# p, pick = use commit# r, reword = use commit, but edit the commit message# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit# f, fixup = like "squash", but discard this commit's log message# x, exec = run command (the rest of the line) using shell# d, drop = remove commit## These lines can be re-ordered; they are executed from top to bottom.## If you remove a line here THAT COMMIT WILL BE LOST.## However, if you remove everything, the rebase will be aborted.## Note that empty commits are commented out</pre> The comments at the bottom tell us what our options are. We can '''pick''' a commit to include it, '''squash''' a commit to combine it with the previous commit (like using <code>git commit --amend</code>), '''fixup''' a commit to squash and throw away the commit message, etc. In our case, let's modify things to include the first commit, and squash the next two into it. To do so, edit the commit message like so, then save and exit your bugeditor: <pre>pick 436a838 Adding animals.txtsquash 595f37e Added water animalssquash 3d7af87 Add jungle animals</pre>  Git responds with the same merge conflict we had previously: <pre>error: could not apply 3d7af87... Add jungle animals When you have resolved this problem, run "git rebase --continue".If you prefer to skip this patch, run "git rebase --skip" instead.To check out the original branch and stop rebasing, run "git rebase --abort". Could not apply 3d7af871d2677c64399c674f6a5937b9bbc48852... Add jungle animals</pre> If you run <code>git status</code> you'll see this: <pre>interactive rebase in progress; onto 21826a9Last commands done (3 commands done): squash 595f37e Added water animals squash 3d7af87 Add jungle animals (see more in file .git/rebase-merge/done)No commands remaining.You are currently rebasing branch 'animals' on '21826a9'. (fix conflicts and then run "git rebase --continue") (use "git rebase --skip" to skip this patch) (use "git rebase --abort" to check out the original branch) Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add <file>..." to mark resolution)  both modified: animals.txt no changes added to commit (use "git add" and/or "git commit -a")</pre> The reason that our rebase is failing is because git is '''replaying''' our commits one-by-one on top of <code>master</code>, and as it does so, it's hitting a commit that is changing the same lines as a previous one. Once again, edit your <code>animals.txt</code> file to combine the merge conflict: <pre>horsecowchicken<<<<<<< HEADwhaleseahorsedolphin=======monkeypythonbird of paradise>>>>>>> 3d7af87... Add jungle animals</pre> Should become:  horse cow chicken whale seahorse dolphin monkey python bird of paradise When you're done, <code>git add animals.txt</code> to signal to git that you've resolve the conflict. Then, you can tell git to '''continue''name'running the rebase (i.e., do the next commit in your list): <code>git rebase --continue</code>. Finally, git finishes replaying all our commits, and gives us a chance to alter our new commit message: <pre># This is a combination of 3 commits.# This is the 1st commit message:Adding animals.txt # This is the commit message #2: Added water animals # This is the commit message #3: Add jungle animals # Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Date: Thu Feb 2 13:01:46 2017 -0500## interactive rebase in progress; onto 21826a9# Last commands done (3 commands done):# squash 595f37e Added water animals# squash 3d7af87 Add jungle animals# No commands remaining.# You are currently rebasing branch 'animals'on '21826a9'issue number.## Changes to be committed:# new file: animals.txt#</pre> You can change it, or leave it as is. Save and exit your editor. In the end, I have a single commit that combines all of my other commits into one: <pre>$ git logcommit afc5bad7f651be478c69c4e117102bfeb183323cAuthor: David Humphrey (:humph) david.humphrey@senecacollege.ca <david.humphrey@senecacollege.ca>Date: Thu Feb 2 13:01:46 2017 -0500  Adding animals.txt  Added water animals  Add jungle animals</pre> ==6. The gh-pages branch== For our final experiment, let's learn how to use Github's special <code>gh-pages</code> branch to host static web content. First, let' s convert our <code>animals.txt</code> file to HTML. Open the file and modify it so it's a proper HTML document, something like this: <pre> <!doctype html> <title>Learning about gh-pages</title> <body> <ul> <li>horse <li>cow <li>chicken <li>whale <li>seahorse <li>dolphin <li>monkey <li>python <li>bird of paradise </ul></pre> Next, <code>commit</code> your change, then use <code>git mv</code> to rename <code>animals.txt</code> to <code>animals.html</code>. Make sure you <code>commit</code> that rename change as well. Now let's create a new branch named <code>gh-pages</code> that points to our current commit on <code>animals</code>: <code>git checkout -b gh-pages animals</code> Next, <code>push</code> your new <code>gh-pages</code> branch to Github and your forked repo: <code>git push origin gh-pages</code> Lastly, we can visit our hosted page at http://{username}.github.io/Spoon-Knife/animals.html. Mine is at https://humphd.github.io/Spoon-Knife/animals.html. There are more instructions [https://help.github.com/articles/configuring-a-publishing-source-for-github-pages/ here]. NOTE: it can take a few minutes for your <code>gh-pages</code> branch to get published. ==Submission== You will have completed your lab when you have done the following: * Completed the steps above to fork the Spoon-Knife repo, and created the various branches, done the merges, rebasing, etc.* Added a row to the table belowwith your '''name''', '''GitHub repo link to your Spoon-Knife fork''', and '''hosted gh-pages URL to your animals.html file'''.* Written a blog post discussing what you learned about branches, merging, rebasing this week.
{| class="wikitable"
|-
| 1
| Dave Humphrey| https://github.com/humphd/Spoon-Knife| https://humphd.github.io/Spoon-Knife/animals.html
|-
| 2
| Simon de Almeida| https://github.com/simon66/Spoon-Knife| https://simon66.github.io/Spoon-Knife/animals.html
|-
| 3
| Kevin Ramsamujh| https://github.com/kramsamujh/Spoon-Knife| https://kramsamujh.github.io/Spoon-Knife/animals.html
|-
| 4
| Timothy Moy| https://github.com/timmoy/Spoon-Knife| https://timmoy.github.io/Spoon-Knife/animals.html
|-
| 5
| Christopher Singh| https://github.com/cgsingh/Spoon-Knife| https://cgsingh.github.io/Spoon-Knife/animals.html
|-
| 6
| John Kim| https://github.com/bkim49/Spoon-Knife| https://bkim49.github.io/Spoon-Knife/animals.html
|-
| 7
| Ray Gervais| https://github.com/raygervais/Spoon-Knife| https://raygervais.github.io/Spoon-Knife/animals.html
|-
| 8
| Heetai Park| https://github.com/tonypark0403/Spoon-Knife| https://tonypark0403.github.io/Spoon-Knife/animals.html
|-
| 9
| Len Isac| https://github.com/lkisac/Spoon-Knife| https://lkisac.github.io/Spoon-Knife/animals.html
|-
| 10
| Dang Khue Tran| https://github.com/dangkhue27/Spoon-Knife| https://dangkhue27.github.io/Spoon-Knife/animals.html
|-
| 11
| Peiying Yang| https://github.com/peiying16/Spoon-Knife| https://peiying16.github.io/Spoon-Knife/animals.html
|-
| 12
| Max Fainshtein| https://mfainshtein4.github.io/Spoon-Knife| https://mfainshtein4.github.io/Spoon-Knife/animals.html
|-
| 13
| John James| https://github.com/JohnEJames/Spoon-Knife/tree/gh-pages| https://johnejames.github.io/Spoon-Knife/animals.html
|-
| 14
| Badr Modoukh| https://github.com/badrmodoukh/Spoon-Knife| https://badrmodoukh.github.io/Spoon-Knife/animals.html
|-
| 15
| Oleg Mytryniuk| https://github.com/omytryniuk/Spoon-Knife| https://omytryniuk.github.io/Spoon-Knife/animals.html
|-
| 16
| Theo Dule| https://github.com/Th30/Spoon-Knife| https://th30.github.io/Spoon-Knife/animals.html
|-
| 17
| Margaryta Chepiga| https://github.com/MargarytaChepiga/Spoon-Knife| https://margarytachepiga.github.io/Spoon-Knife/animals.html
|-
| 18
| Xiao Lei Huang| https://github.com/davidhuang1550/Spoon-Knife| https://davidhuang1550.github.io/Spoon-Knife/animals.html
|-
| 19
| Dmytro Sych| https://github.com/dsych/Spoon-Knife| https://dsych.github.io/Spoon-Knife/animals.html
|-
| 20
| Zenan Zha| https://github.com/ZenanZha/Spoon-Knife/| https://zenanzha.github.io/Spoon-Knife/animals.html
|-
| 21
| Jerry Goguette| https://github.com/twigz20/Spoon-Knife| https://twigz20.github.io/Spoon-Knife/animals.html
|-
| 22
| Wayne Williams| https://github.com/Blackweda/Spoon-Knife| https://blackweda.github.io/Spoon-Knife/animals.html
|-
| 23
| Eugueni Antsyferov| https://github.com/evantsyferov/Spoon-Knife| https://evantsyferov.github.io/Spoon-Knife/animals.html
|-
| 24
| Nagashashank P| https://github.com/Shank09/Spoon-Knife| https://shank09.github.io/Spoon-Knife/animals.html
|-
| 25
| Shivam Gupta| https://github.com/sgupta7857/Spoon-Knife| https://sgupta7857.github.io/Spoon-Knife/animals.html
|
|-
| 26
| Maya Filipp| https://github.com/Mordax/Spoon-Knife| https://mordax.github.io/Spoon-Knife/animals.html
|-
| 27
| Eduardo Sorozabal| https://github.com/edyedy123/Spoon-Knife| https://edyedy123.github.io/Spoon-Knife/animals.html
|-
| 28
| Rahul Gupta| https://github.com/rkgupta21/Spoon-Knife| http://rkgupta21.github.io/Spoon-Knife/animals.html
|-
| 29
Teddy Prempeh
https://github.com/teddypee/Spoon-Knife
|
|
|-
| 35
|
|
|
|-
| 36
|
|
|
|}
 
==Submission==
 
You will have completed your lab when you have done the following:
 
* Setup Bramble and Thimble on your local computer, and taken a '''screenshot''' of it running in your browser
* Picked a '''bug''' to fix in Thimble
* Written a blog post discussing what it was like setting up Thimble, what you learned, and which bug you chose. What is the bug about?
* Added a row to the table above with your '''name''', '''issue URL''', and '''blog post URL'''.
22
edits

Navigation menu