This homework aims at giving you some experience with creating Git branches, developing your project on multiple branches, merging them, resolving potential conflicts between different branches upon merging, and finally how to delete them. It also gives you some experience with using other commonly-used Git commands. Write your 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 highlighted as bash code, in your readme.md file.

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





1.  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 readme.md file inside your homework/2/ 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 homework-2 folder to your local repository. Throughout the rest of this homework, you will fill this readme.md file with your answers.

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

(B) Now checkout the test1 branch and create a new text file named test.txt in the homework/2/ directory of this branch.

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

(D) Now stage and commit test.txt file to branch test1.

(E) Checkout the branch test2. Do you still see test.txt that you just created in your homework/2/ 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.

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

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

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

(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.)

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

(K) Now chekcout test2. What error/warning message do you get?

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

(M) At this stage, you have two options: Either 1. stage and commit the combined conlifting test.txt file to Git repository (but this is not recommended), or, 2. open the file test.txt using vim editor on the command line and reslve the conflict by editing the content of the file to only this sentence: . Then save and quit *vim.

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

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

(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.

(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?

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

(S) Switch back to master and delete test2 branch. List all your project branches by the approproiate Git command.

(T) Stage and commit all the changes (including the file test.txt) to your project’s master branch. Now push it all to the remote repository by Wednesday Feb 15 2017, 9:00 a.m. CDT.





2.  Create a branch gh-pages for your project from master, such that your project is accessible through its web address based on the content of gh-pages branch, not based on the content of master branch.


Comments