Linux and Command-Line Basics
You ran git commit in Git, but the commit does not yet appear in the GitHub repository shared by the team. Which of the following is the reason?
- Agit commit only registers changes in the staging area, and git add is needed to record them
- BSending committed changes to the shared repository requires running git pull
- Cgit commit records in the local repository, and git push is needed to send it to the remote
Show answer and explanation
Answer: C. git commit records in the local repository, and git push is needed to send it to the remote
Git is a distributed version control system in which each developer has the whole repository locally, and git commit records changes in that local repository. To send them to a remote repository such as GitHub, git push is run; conversely, git pull (or git fetch and git merge) brings new remote commits into the local repository. This is why commits can be made without a network connection and pushed together later. If someone else has pushed first, you may be asked to bring in their changes first.
- A. The roles of git add and git commit are reversed. add stages and commit records.
- B. git pull brings remote changes into the local repository; sending local commits is done with git push.
- C. Correct. commit records locally, and push sends to the remote.