Notes on GIT
I’m not using git
often enough to be confortable with uncommon utilizations. Here are some notes about what I’ve trouble to remember.
Acting on the worktree and the stage (aka index)
git restore files
copy files from the stage to the worktree
git restore –staged|-S files
copy files from the HEAD to the stage
git restore –staged|-S –worktree|-W files
copy files from the HEAD to both the stage and the work tree.
git add files
copy files from the work tree to the stage.
git commit
create a new commit from the stage.
Acting on the current branch
git reset –soft commit
change the commit of the branch, but does not change the stage nor the work tree.
git reset [–mixed] commit
change the commit of the branch, change the stage to the content of the commit but does not change the work tree.
git reset –hard commit
change the commit of the branch, the stage and the work tree.
Changing the branch
git checkout branch
switch to branch.
git checkout -b branch
create a new branch and switch to it.