Module 2 Exercise 3: Wikipedia Switcheroo


(Vanessa) #1

Exercise: Wikipedia switcheroo

  1. Create a repository on your desktop called ‘planets’ with a readme.md and commit it.
  2. Choose a Wikipedia page about a planet of your choice.
  3. Copy the first paragraph about the planet, paste it into your readme.md and commit it.
  4. Create a new branch (git branch ) and switch to it (git checkout ).
  5. In atom, add Wikipedia entry about another planet into that branch’s readme.
  6. Save, then commit, then close out of atom.
  7. Does the file show your first planet? Or the second?
  8. Take a screenshot of your output and post it below.

Module 2 Exercise 2: Recreate Your Assignment Workflow
(Eric Allatta) #2

The new branch contains both the first and second paragraph. When the new branch was created it started at the last commit.


(Ryan Schuetzler) #3


(Clara) #4

The readme.md for the new branch has both planets. If master is checked out, readme.md only has the first.


(François Roland) #5


(Richard) #6

Both planets are represented as the branch happened after the first commit and the instructions asked to add to the file, not replace the contents.


(James ODonnell) #7

image
I did my editing outside of the console. The file inside of the folder on my harddrive (also the git repo) has changed from Mercury to Saturn; but this change has not yet been merged into the master branch


(Mike Crabb) #8

Branch will have information about both planets, but if we go back into master it will only have information about the first.


(Ricardo Martin Marcucci) #9

It has information about both planets, but branch master has only info about the first one.


(Omal Perera) #10

Module 2 Exercise 3 : Completed :white_check_mark:

As the second branch is pointed on the first branch, both paragraphs are available in the readme.md.

Cheers! :tada:


(Mario Jorge Pereira) #11

Master branch first text.
Second branch the other text.
The text will change according to the branch


(Luigi Menale) #12

The branch contains the first line and of course the second line.


(Benjamin Soltoff) #13
Last login: Thu Mar  1 13:37:02 on ttys000
Benjamins-MacBook-Pro:~ soltoffbc$ git init planets
Initialized empty Git repository in /Users/soltoffbc/planets/.git/
Benjamins-MacBook-Pro:~ soltoffbc$ cd planets/
Benjamins-MacBook-Pro:planets soltoffbc$ touch readme.md
Benjamins-MacBook-Pro:planets soltoffbc$ nano readme.md 
Benjamins-MacBook-Pro:planets soltoffbc$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	readme.md

nothing added to commit but untracked files present (use "git add" to track)
Benjamins-MacBook-Pro:planets soltoffbc$ git add readme.md 
Benjamins-MacBook-Pro:planets soltoffbc$ git commit -m "Add info on Earth"
[master (root-commit) eb35ed3] Add info on Earth
 1 file changed, 2 insertions(+)
 create mode 100644 readme.md
Benjamins-MacBook-Pro:planets soltoffbc$ git branch earth
Benjamins-MacBook-Pro:planets soltoffbc$ git checkout earth
Switched to branch 'earth'
Benjamins-MacBook-Pro:planets soltoffbc$ git status
On branch earth
nothing to commit, working tree clean
Benjamins-MacBook-Pro:planets soltoffbc$ git checkout venus
error: pathspec 'venus' did not match any file(s) known to git.
Benjamins-MacBook-Pro:planets soltoffbc$ git branch venus
Benjamins-MacBook-Pro:planets soltoffbc$ git checkout venus
Switched to branch 'venus'
Benjamins-MacBook-Pro:planets soltoffbc$ git add readme.md 
Benjamins-MacBook-Pro:planets soltoffbc$ git commit -m "Change readme to Venus"
[venus 45d9129] Change readme to Venus
 1 file changed, 1 insertion(+), 2 deletions(-)
 rewrite readme.md (100%)
Benjamins-MacBook-Pro:planets soltoffbc$ git status
On branch venus
nothing to commit, working tree clean
Benjamins-MacBook-Pro:planets soltoffbc$ cat readme.md 
Venus is the second planet from the Sun, orbiting it every 224.7 Earth days.[12] It has the longest rotation period (243 days) of any planet in the Solar System and rotates in the opposite direction to most other planets. It does not have any natural satellites. It is named after the Roman goddess of love and beauty. It is the second-brightest natural object in the night sky after the Moon, reaching an apparent magnitude of −4.6 – bright enough to cast shadows at night and, rarely, visible to the naked eye in broad daylight.[13][14] Orbiting within Earth's orbit, Venus is an inferior planet and never appears to venture far from the Sun; its maximum angular distance from the Sun (elongation) is 47.8°.
Benjamins-MacBook-Pro:planets soltoffbc$ git checkout earth
Switched to branch 'earth'
Benjamins-MacBook-Pro:planets soltoffbc$ cat readme.md 
Earth is the third planet from the Sun and the only object in the Universe known to harbor life. According to radiometric dating and other sources of evidence, Earth formed over 4 billion years ago. Earth's gravity interacts with other objects in space, especially the Sun and the Moon, Earth's only natural satellite. Earth revolves around the Sun in 365.26 days, a period known as an Earth year. During this time, Earth rotates about its axis about 366.26 times.

I accidentally replaced the contents of README.md rather than add a new line. But the point is the same - the file contains the updated version of README.md rather than the original because we are still checked out into the updated branch. Switching back to the original branch removes the updates because the commit was made previously.


(Randy Johnson) #14

Both planets are shown, since Mercury branched off after Jupiter was added to the README


(James ODonnell) #15


reset file that had been staged to only commit other file


(Péter Kalicz) #16

image


(Rishabh Bansal) #17

Hi @mozzadrella! Here is my Module 2 Exercise 2.4 Submission!


(Miren Berasategi) #18


The readme.md was populated with the text from the first planet. It’s only showing the second planet now, but because I replaced the original text (as shown in the screenshot).


(Derek Land) #19


The branched readme.md has all the planets. The master branch only the first one (no merging yet…).


(Nbzeman) #20

I’m adding this Discussion on Module 2, Exercise 4, for my screenshot of the planets repo.