/
4. Working with Remote (branches)

4. Working with Remote (branches)

Verify the status of the local repo using git status, everything should be up to date.

Push the changes to the remote repo git push origin main

Create a branch called feature/the_rev_is_happening using the command git checkout -b feature/the_rev_is_happening

Add the following lines of text (or something that appeals to you) between the two verses of the original poem

From the Indians who welcomed the pilgrims And to the buffalos who once ruled the plain Like the vultures circling beneath the dark clouds Looking for the rain Looking for the rain Just like the cities staggered on the coastline In a nation that just can't stand much more Like the forest buried beneath the highway Never had a chance to grow Never had a chance to grow

So the poem should look like this

I keep six honest serving-men (They taught me all I knew); Their names are What and Why and When And How and Where and Who. I send them over land and sea, I send them east and west; But after they have worked for me, I give them all a rest. From the Indians who welcomed the pilgrims And to the buffalos who once ruled the plain Like the vultures circling beneath the dark clouds Looking for the rain Looking for the rain Just like the cities staggered on the coastline In a nation that just can't stand much more Like the forest buried beneath the highway Never had a chance to grow Never had a chance to grow I let them rest from nine till five, For I am busy then, As well as breakfast, lunch, and tea, For they are hungry men. But different folk have different views; I know a person small She keeps ten million serving-men, Who get no rest at all! She sends em abroad on her own affairs, From the second she opens her eyes One million Hows, Two million Wheres, And seven million Whys! A poem by Rudyard Kipling

Stage, commit, and push the changes - git add ., git commit -m "Added Winter in America Lyrics", and finally git push origin feature/the_rev_is_happening

If you are using git bash, it should be visible which branch you are on. if you are not using git bash, type git branch to see which branch you are one.

Goto to your remote repo, refresh the web page, and look for the branches. You should see your branch is now visible.

Back on your machine, switch back to the main branch git checkout main

Notice that the text file six_honest_serving_men.txt reverts back to its original state. In actual fact, it hasn’t reverted, it’s simply showing a different truth on a different branch.

It’s good practice to develop off branches and merge those changes into the main/develop branch (typically called known as trunk - main/develop).

Merging changes from remote into main

We are going to simulate another team member merging the remote changes into the main branch

Create another folder called tm2 (not as a child off the current folder which should already be a git repo)

Clone the poetry project down into the tm2 folder using the command git clone <git repo URL>

Navigate into the poetry folder, it should default to the main branch.

Examine the file six_honest_serving_men.txt. Notice that it has the original poem content not the lines from the other poem.

Pull the changes of the remote branch feature/the_rev_is_happening into main

git pull origin feature/the_rev_is_happening

Examine the file six_honest_serving_men.txt. Notice that it has been updated. We need to update the remote repo.

Visit your remote repo and you should see that the main branch on the remote repo has been updated.