Module 2 Exercise 3: Wikipedia Switcheroo


(Amy Dickens) #101

Great work here :+1:

What was the output when you looked at the two different branches? Were you able to see the difference between the files? :sparkles:


(Amy Dickens) #102

Hi @bassgruv the atom . command using these steps:

Setting Up Terminal Access for Atom

One of the things you’ll do frequently is open an entire folder (like when working on a project) in your text editor. Let’s get that setup:

  • Open Atom ( command-spacebar for spotlight, type Atom , and hit enter).
  • Click the Atom menu in the top left corner
  • Click Install Shell Commands
  • Return to your terminal and enter which atom . You should get back /usr/local/bin/atom
  • Enter atom . to open your user directory in Atom.
  • Experiment with creating a file in Atom and using ls in the terminal to see it. Try creating a file in the terminal with touch and see if it shows up in Atom.

Hope this helps :sparkles:


(Amy Dickens) #103

Hi @mrculpMHS :wave:

In this exercise we are looking at creating branches and observing the difference when we edit a file across two branches.

It looks like you have submitted one of the earlier exercises as your screen shot here.

Click this link for the original post that contains the instructions on how to complete this exercise.

Let me know if you need any help :sparkles:


(Amy Dickens) #104

Hi :wave:

You seem to have submitted the same screenshot twice here - was that a mistake?

Also what did you notice about your readme.md file across the two branches?

:sparkles:


(Amy Dickens) #105

Thanks for the feedback @pumatech :sparkles:

Is there anything you think we could do to make it more clear?

As it happens this is exactly what we are looking for :raised_hands:

Great work :tada:


(Amy Dickens) #106

Interesting :thinking:

What branch were you on when looking at the file in Atom?

A little more context will help to understand what was happening here :blush:


(Lescano Micaela) #107

On newBranch I can see both paragraphs, whereas in master branch you can only see the first paragraph as expected.


(Jaime Rabasco Ronda) #108

I can see both descriptions


(Adarshreddy adelli) #109

It prints both … what i observed is it creates a clone and allows user to modify


(Isg75) #110

Hi,

Here is my solution. The readme.md shows the text of both planets as the readme.md is created into another branch WHICH starts from the previous commit!

if I switch back to ‘master’ branch, then the readme.md will only show the info about the initial planet


(mexcalli) #111

Both descriptions are included


(Claudio Santoro) #112

As we can see with git show mars, our first planet content was removed and replaced by Mars content.


(Vasil Markov) #113

The readme.md shows the text of both planets if you are in the branch newplanet, but if you are in the master you see only the firstone.


(Diego Fernando Marin) #114

Module 2 Exercise 4 done!

The master branch only have the text of first planet, my saturn branch have the text of both.


(Dr. Ayaz H. Khan) #115

Yes sure.
In this I created a repository “Planet” containing two branches. One is the master (default) branch and another atom branch. Each branch contains the information related to different planets.


(Sara Marín-López) #116

I can see both paragraphs because “NewBranch” is currently my active branch. If I switch to “Master” I only see one of them :+1:


(Ali Bayram) #117

Both texts are visible in newbranch.


(Mihaela Sabin) #118

mcs_admin labs $ git init planets

Initialized empty Git repository in /Users/mcs_admin/comp7805/2018-fall/labs/planets/.git/

mcs_admin labs $ ls

individual-work lab1start planets

mcs_admin labs $ cd planets/

mcs_admin (master #) planets $ ls

mcs_admin (master #) planets $ sublime readme.md

mcs_admin (master #) planets $ less readme.md

mcs_admin (master #) planets $ 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)

mcs_admin (master #) planets $ git add readme.md

mcs_admin (master +) planets $ git commit -m ‘create readme and edit planet venus info’

[master (root-commit) 3b526df] create readme and edit planet venus info

1 file changed, 1 insertion(+)

create mode 100644 readme.md

mcs_admin (master) planets $ git log

commit 3b526df355009002f7167740458bcdc069b4aa0a ( HEAD -> master )

Author: Mihaela Sabin <mihaela.sabin@unh.edu>

Date: Tue Sep 11 07:49:33 2018 -0400

create readme and edit planet venus info

mcs_admin (master) planets $ git branch neptune

mcs_admin (master) planets $ git branch

  • master

neptune

mcs_admin (master) planets $ git checkout neptune

Switched to branch ‘neptune’

mcs_admin (neptune) planets $ git branch

master

  • neptune

mcs_admin (neptune) planets $ less readme.md

mcs_admin (neptune) planets $ sublime readme.md

mcs_admin (neptune) planets $ git status

On branch neptune

Changes not staged for commit:

(use “git add <file>…” to update what will be committed)

(use “git checkout – <file>…” to discard changes in working directory)

modified: readme.md

no changes added to commit (use “git add” and/or “git commit -a”)

mcs_admin (neptune *) planets $ git add readme.md

mcs_admin (neptune +) planets $ git commit -m ‘insert planet neptune info’

[neptune 01c5574] insert planet neptune info

1 file changed, 3 insertions(+), 1 deletion(-)

mcs_admin (neptune) planets $ git log

commit 01c5574b795afb210a2e7c2f6cd2fca4aad928a5 ( HEAD -> neptune )

Author: Mihaela Sabin <mihaela.sabin@unh.edu>

Date: Tue Sep 11 07:52:47 2018 -0400

insert planet neptune info

commit 3b526df355009002f7167740458bcdc069b4aa0a ( master )

Author: Mihaela Sabin <mihaela.sabin@unh.edu>

Date: Tue Sep 11 07:49:33 2018 -0400

create readme and edit planet venus info

mcs_admin (neptune) planets $ less readme.md

mcs_admin (neptune) planets $ git checkout master

Switched to branch ‘master’

mcs_admin (master) planets $ git branch

  • master

neptune

mcs_admin (master) planets $ less readme.md

mcs_admin (master) planets $


(Dr. Ayaz H. Khan) #119

sorry not to attach the screenshot before.
Here it is now.


(Yann Thierry-Mieg) #120
[ythierry@localhost demo3]$ git init testmerge
Initialized empty Git repository in /data/ythierry/home/ythierry/cours/github/work2/demo3/testmerge/.git/
[ythierry@localhost demo3]$ cd testmerge/
[ythierry@localhost testmerge]$ cat >> readme.md
My favorite planet is inhabited by Le Petit Prince                                   
[ythierry@localhost testmerge]$ 
[ythierry@localhost testmerge]$ git commit -m 'init'
On branch master

Initial commit

Untracked files:
        readme.md

nothing added to commit but untracked files present
[ythierry@localhost testmerge]$ ls
readme.md
[ythierry@localhost testmerge]$ git add readme.md 
[ythierry@localhost testmerge]$ git commit -m 'init'
[master (root-commit) 941a9d7] init
 1 file changed, 1 insertion(+)
 create mode 100644 readme.md
[ythierry@localhost testmerge]$ git branch other
[ythierry@localhost testmerge]$ git checkout other
Switched to branch 'other'
[ythierry@localhost testmerge]$ cat >> readme.md
But I live on Earth :(
[ythierry@localhost testmerge]$ git add readme.md 
[ythierry@localhost testmerge]$ git commit -m 'other planet'
[other c32a033] other planet
 1 file changed, 1 insertion(+)
[ythierry@localhost testmerge]$ cat readme.md 
My favorite planet is inhabited by Le Petit Prince
But I live on Earth :(
[ythierry@localhost testmerge]$