Git & Unix cheat sheet

It’s time for the Git cheat sheet for writers!

General command structure:

command -o --option argument "another argument, containing blank spaces"

Note that Git commands always start with the prefix git whereas Unix commands do not carry a prefix.

Unix commandDescription
pwdPrint working directory = tell me which folder I am in
lsList all items in this directory
cd <directory-path>Change directory by indicating where to go (path to directory)
cd ..Move up one level
cd .. = “this directory”, so cd . = stay where you are. (However, the one dot is useful in, e.g.: git add .)
cd ~~ = home directory, so cd ~ = go to home directory.
cd ~/<some-directory>Go to some-directory right below the home directory
mkdirMake directory (Note: Creating a new directory won’t move you to that new directory. You’ll have to use cd <directory> to go there.)
mv <current-file-name.xyz> <new-file-name.xyz>Move file = rename it, or (Git logic): delete old file and create new file (that is thus unstaged)
rm <filename.xyz>Remove file = delete it
[Tab] keyFill in the rest of a name
[Up arrow] keySelect the previous command (move back in time)
[Backspace] keyGo backwards (in a line)
[Space] keyGo forward (in a line) or: scrolls down
[q] keyQuit the execution of a command
General Unix commands used in Peter Gruenbaum’s course Git and GitHub for Writers
Git commandDescription
git --versionShows installed Git version
git clone <repository-path>Right-click to paste the copied repository URL into Git Bash
git statusShows the status of the files/ the repo, e.g., unstaged files
git add <filename.xyz>Stages a particular file
git add .Stages all files in the current directory
git commit -m "Your commit message"Commits all staged files with the message provided
git push [<repo> <branch>]Uploads changes (all commits) to repository. Note that you have to be signed in to the repo server to be able to push changes.
git push origin <your-branch>Uploads the changes to your-branch of the default repo (=origin)
git config --global user.email "<youremail@domain.xyz>"Sets default identity for Git (1/2). Omit --global to set the identity only for the repository you are currently working on.
git config --global user.name "<Your Name>"Sets default identity for Git (2/2).
git logShows the repo’s history
git log --onelineShows a compact version of the history, including commit numbers
git checkout <commit-number>Sets the HEAD label to a certain commit (= all documents will be displayed according to their state at the time of that commit)
git checkout masterSets the HEAD label back to the most recent commit on the master branch
git checkout <your-branch>Sets the HEAD label back to the most recent commit on your-branch
Basic Git commands used in Peter Gruenbaum’s course Git and GitHub for Writers

Read more about how this cheat sheet came to be:


How I learned Git, forgot it, and re-learned it

Part 1: Why you need to learn Git for Docs as Code Docs as Code. What? In the software industry, technical writers work close to developers, especially when writing developer documentation, that is, documents that have other developers as target users. The idea of Docs as Code is to employ the same workflows for the…

Leave a comment