Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help with these git questions I will thumbs up in rating !!! 1) You creat

ID: 3917488 • Letter: P

Question

please help with these git questions

I will thumbs up in rating !!!

1) You create a directory on your local computer for a project and put some files in it and initialize it as a git repo. Then, you create a repo on GitHub for the project that is initialized with a .gitignore and a README.md. You then attempt to execute the following in a terminal window on the local computer:

git pull origin master

This results in the message, "fatal: refusing to merge unrelated histories".

What do you need to do in order for the pull to work?

A) Remove all tracking of files in the local repo using git rm -r --cached then do the pull.
B) Add --rebase to the git pull.
C) Remove the .git directory from the project directory on the local computer then do the pull.
D) Just execute the same command again and it will work.

2) Development of new features should happen on the master branch.

A) True
B) False

3) You are working on a bug fix on a branch called bugfix/memoryleak that you have completed and tested. You want to merge the bug fix into the master branch. Which of the following do you do?

A) While in the bugfix/memoryleak branch, execute git merge master.
B) Switch to the master branch using git checkout master, then execute git merge bugfix/memoryleak.
C) While in the bugfix/memoryleak branch, execute git pull master.
D) Switch to the master branch using git checkout master, then execute git merge master.

4) To create a branch, you run git branch. How can you create a branch and switch to it in one command?

A) git branch --switch <branch-name>
B) git checkout -b <branch-name>
C) git branch --checkout <branch-name>
D) git checkout --create-branch <branch-name>

Explanation / Answer

****************************Answer**************************

1)git pull origin master

This results in the message, "fatal: refusing to merge unrelated histories".

What do you need to do in order for the pull to work?

###########################

Remove all tracking of files in the local repo using git rm -r --cached then do the pull.

We are getting that error because of in our local system we have some changes that are not in git so its not accepting us to pull the code from the git. So to pull the code either we have to remove the changes or do the git stash and then pull the code after that do git stash apply then your changes will come again and it will pull the new code from git.

2) Development of new features should happen on the master branch.

False

Because actually we do development on developement branch and if everything is fine then we will merge that code to the master. To ensure that the code in master is always error free, If we have any errors that has to be resolved in developement stage only.

3) You are working on a bug fix on a branch called bugfix/memoryleak that you have completed and tested. You want to merge the bug fix into the master branch. Which of the following do you do?

Switch to the master branch using git checkout master, then execute git merge master.

First we have to checkout to the master and then merge using the command git merge branch_name and we have to push this changes to the master.

4) To create a branch, you run git branch. How can you create a branch and switch to it in one command?

B) git checkout -b <branch-name>

by using this command we can create the new branch and we will checkout to that branch.