Git commands explained

A translation of common Git commands in normal, understandble(?) words.

git add : Stage a file. Add it from your workspace into the staging area (or index). Workspace edits is not changed. After this add command, your files are ready to be committed (by a commit command later)

git rm — cached : Unstage a file. Remove the file from the staging area. Workspace edits is not changed. After this rm command, your file is not longer ready to be commited.

git commit : Bundle all the files that are in the staging area and copy them to the local repository. After a commit command, the staging area is empty again, and your bundle of files is nicely stored in the repository with a date, author and description. They have become part of the history.

git checkout : Updates files in the workspace to match the contents of another branch or commit. After this checkout you are ready to continue programming but you are (re-)starting from another point in the tree or in thetimeline.

git revert : Create a a bundle of files that contains the necessary changes to undo a commit. After this revert command you have created a NEW(!) commit that reverses an earlier commit.

git reset –soft : Undo a change (commit) in the local repository. After this reset we are ready to (re-)commit again.

git reset (–mixed) : Undo a change (add) in the staging area. After this reset we are ready to (re-)add again.

git reset –hard : Undo a change (local edit, aka programming) in the workspace.After this reset we lost our changes and are ready to (re-)edit again. This only effects tracked files.

git clean -f -d : Removes all the untracked files and folders with untracked files from the workspace. After this clean you can start adding ew files. Use -n instead of -f to inspect the files/folders before actuallty deleting them.


Leave a comment