Git

Guidelines. Use the following Markdown language references, or any other reference that you find or prefer, to perform the tasks requested in this question.

Write the code sections of your answer in Markdown syntax. For example,

```bash
$ git branch -d test
error: Cannot delete branch 'test' checked out at 'C:/Users/Amir/git/foo'
```

will display the following text as highlighted bash code, in your readme.md file (although with a different highlighting and colors).

$ git branch -d test
error: Cannot delete branch 'test' checked out at 'C:/Users/Amir/git/foo'

Problem Part 1

Include the following information with the following format and information in your main directory readme.md file (note that anything that appears in <> is supposed to be provided by you):

Beginning of the README file’s content

<Project Name> - <Course Name> (<Season> <year>)


Name: <first name> <last name>
School ID: <your ID>
Email: <your email>
Department: Department of <your department>
University: The University of <your university>
Level: <undergraduate or graduate> - <Freshman (1st year) / Sophomore (2nd year) / Junior (3rd year) / Senior (4th year) / Dinosaur (5th year and above) >
Position Title: Student
Course Webpage: <the course’s website, if any>
Photo (ATTN: should display your photo, not mine!):

Amir Shahmoradi

Description of the project’s content

This repository contains my homework, quizzes, and virtually every effort that I have made for <course name>. The structure of the project is the following:

  • homework: (the homework hyperlink should take the reader to the homework folder)
    This directory contains all my homework submissions, each of which is a folder properly named with homework number, containing the homework submission.

  • quiz: (the quiz hyperlink should take the reader to the quizzes folder)
    This directory contains all my quiz submissions, each of which is a folder properly named with quiz number, containing the quiz submission.

  • exam: (the exam hyperlink should take the reader to the exams folder)
    This directory contains all my exam submissions, each of which is a folder properly named with exam name or number, containing the exam submission.

For questions and troubleshooting, please contact:

<your name>
<your email>
<any other contact or signature information that you would like to add>

I have not failed. I’ve just found 10,000 ways that won’t work.
Thomas A. Edison

End of the README file’s content

Problem Part 2.A

Create two additional test branches in your project, each of which is branched directly from master. For each of the following cases, write the command and the corresponding output message of Git, in Markdown language in a file named readme.md inside your homework/VCS/ folder in your master branch. If you don’t have this folder in your project, then create the folder and then place your initial readme.md file in this folder with your signature as the content of the file. Then stage and commit this file together with the homework folder to your local repository. Throughout the rest of this homework, you will fill this readme.md file with your answers.

Create two branches, both from your master branch, with names test1 and test2.

Problem Part 2.B

Now check out the test1 branch and create a new text file named test.txt in the homework/VCS/ directory of this branch.

Problem Part 2.C

Inside test.txt in test1 branch write this message: This is some example text for branch test1, and save it.

Problem Part 2.D

Now stage and commit test.txt file to branch test1.

Problem Part 2.E

Checkout the branch test2. Do you still see test.txt that you just created in your homework/VCS/ directory? You can search for it by the bash command ls. Explain why you see/don’t see the file in your working directory anymore.

Problem Part 2.F

Create a new text file named test.txt in the homework/VCS/ directory of this branch as well, and add This is some example text for branch test2 to its content.

Problem Part 2.G

Now try to checkout test1. What error/warning message do you get? Fix the source of error and then checkout test1 branch.

Problem Part 2.H

Now merge the content of test1 with master branch. (Hint: Note from which branch you doing this merge!)

Problem Part 2.I

Now, what do you see as the content of master branch? (Hint: Use ls bash command, to list the files in the working directory.)

Problem Part 2.J

Now merge the content of test2 with master branch. What error/warning message do you get? Why does this error arise?

Problem Part 2.K

Now checkout test2. What error/warning message do you get?

Problem Part 2.L

Run the Git command git status. Why does such a conflict exist, as mentioned in git status output?

Problem Part 2.M

At this stage, you have two options: Either,

  1. (not recommended) stage and commit the combined conflicting test.txt file to Git repository or,
  2. open the file test.txt using vim editor on the command line and resolve the conflict by editing the content of the file to only this sentence,
    This is some example text from both test1 and test2 branches combined.
    

    Then save and quit vim.

Problem Part 2.N

Now, run git status, then stage and commit your conflict-resolved file. Then checkout test2 branch.

Problem Part 2.O

Now, try deleting branch test1, while on the branch test2. What error/warning message do you get?

Problem Part 2.P

Now, switch back to master branch. Now, try deleting branch test1, while on master branch. What message do you get from Git? List all the existing branches using git branch command.

Problem Part 2.Q

Why is there such a difference in Git messages between when you tried deleting test1 branch from test2 branch, and when you tried deleting test1 branch from master branch?

Problem Part 2.R

Now checkout test2 branch. While on test2, try to delete branch test2. What error/message do you get?

Problem Part 2.S

Switch back to master and delete test2 branch. List all your project branches by the appropriate Git command.

Problem Part 2.T

Stage and commit all the changes (including the file test.txt) to your project’s master branch. Now push all to the remote repository.

Comments