Please answer all of the following. Describe the following git concepts : Local
ID: 3722080 • Letter: P
Question
Please answer all of the following.
Describe the following git concepts:
Local repository:
Staging area:
Remote Repository:
Branch:
2. What is the difference between staging area and local repository
3. What does the git init command do?
4. What are the two git commands that you should use to commit your changes (edits and/or new files) to the local repository
5. From the concepts in question a, where are the files after you execute step 1.5 of the tutorial?
6. Where are the files after you execute step 1.6 of the tutorial?
7. What git command should you use to check for changes on our GitHub repository and pull down any new changes?
8. What git command should you use to take a look at what is different from our last commit?
9. What does it mean to “unstage files” and what git command do you use to unstage files?
10. What git command do you use to change files back to how they were at the last commit?
11. What git command do you use to switch between branches?
Explanation / Answer
1)
Local Repository: Local repository resides on your computer, and you can make changes to it even when you are offline. You can push the changes to any other repository once you are back online
Staging Area: Staging area lies between your working directory and the repository. Suppose you are working on two modules, and one is finished, while the other one is left, you stage the files of the first module, which are marked in the staging area, and then when you commit are saved to your repository
Remote Repository: A centralized server in Git is also referred to as Remote Repository. There is only one remote repository per team or group of members working on a project. Once you are ready to share your work with your team, you push it to the remote repository. Someone else's local repository can be your remote repository.
Branch: A branch in git is an independent line of development. It has its own staging area and a local repo. This prevents the main workspace from getting affected by buggy code. It is just a new pointer to the last successful commit to the repository
2) Staging area contains the files to which changes were made, and were staged using git 'add' command. The files present in the staging area are not saved to the repository unless a commit is explicitly made by the developer, while in the repository, the committed files are present
3) Git init creates an empty git repository. It creates a directory with .git extension, and makes the subfolders 'objects','refs/heads','refs/tags'. If you run git init in an existing folder, it does not overwrite the contents of the file.
4) The two git commands used to commit changes are, add/stage or commit.
7) The command used to check for changes in a git repository is "git diff" command. If you want to see what you haven't added in git, use "git diff yourFile.txt". Else "git diff --cached yourfile.txt", and to pull down new changes use the "git pull" command
8) The last commit is stored in HEAD. To get the difference between current and last commit use, "git diff HEAD"
9) To unstage files basically means to make some changes to the files in the staged area. "git reset <filePath>" is the git command used to unstage files
10) To change files back to the last commit use "git reset --hard HEAD" where HEAD is the last commit in your current branch
11) "git checkout branch_name" is used to switch between branches.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.