Answers
Here are the answers to the questions given above:
- Creating a new commit makes a new node in the graph of revisions that has a previous commit as a parent, advances the branch head ref for the current branch to the freshly created node, and keeps
HEAD
unchanged. - The
git commit
operation creates the new commit out of the staging area contents, while thegit commit --all
creates it out of the changes to all tracked files. - You can use
git status
to examine what files have changed andgit diff
orgit diff HEAD
to examine the changes. You can find the explanation of how to undo changes you have made in the fullgit
status
output. - To change the commit message (that is, the description of the changes) of the last commit, you can use
git
commit --amend
. - Because uncommitted changes do not belong to a branch, you can simply create a new branch and switch to it with
git switch -c <branch-name>
orgit checkout -
b <branch-name>
. - To switch to the previous...