Skip to content

Instantly share code, notes, and snippets.

@SwanX1
Last active August 30, 2021 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SwanX1/da762ce2d3b0ec08820df82b761936a6 to your computer and use it in GitHub Desktop.
Save SwanX1/da762ce2d3b0ec08820df82b761936a6 to your computer and use it in GitHub Desktop.

Infernal Studio's
Supreme Cheat Sheet

To request additions, message Swan#7488 on Discord.


Table of contents:




Git

Introduction to Git

Git is a distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Think of a repository as a project folder. It contains information about itself, any remote repositories, its branches, commits and changes.
All of the information about the repository is saved in the .git subdirectory.

The Three Stages

Working changes
Otherwise known as "unstaged", these are changes that are not stored in other places.

Staged changes
Unlike unstaged changes, these changes are stored locally, and can be thought as an intermediary between unstaged changes and commits.

Commits
Commits are the real deal, they store changes in their respective branch, they contain information about what changes they hold and which commits come before them. They can be pushed to remote repositories, like GitHub.


Before you use any commands: Replace any names within square brackets with their corresponding names.
Do not write the $ in your terminal, they indicate a start of a new command, the rest indicates console output.


Initializing a repository

The git init command creates an empty Git repository - basically a .git directory with its corresponding subdirectories.
$ git init
Initialised empty Git repository in /path/to/repository/.git/
If you run this command in an existing repository, it will not overwrite any files:
$ git init
Reinitialised existing Git repository in /path/to/repository/.git/

Staging files

$ git add [file]
I'd recommend using . as the file, as it includes everything. You can also use the -v flag, because it outputs what has been staged.
$ git add . -v
add 'src/main/java/com/example/AddedFile.java'
remove 'src/main/java/com/example/RemovedFile.java'

Branches

Listing branches

This command will list all branches.
Existing branches are listed, and the current branch will be highlighted in green and marked with an asterisk.
The -r option causes the remote-tracking branches to be listed.
The -a option shows both local and remote branches.
$ git branch
  dev
* master
  stable

$ git branch -a
  dev
* master
  stable
  remotes/origin/dev
  remotes/origin/master
  remotes/origin/stable

Creating a branch

$ git branch [branch]

Renaming (moving) a branch

$ git branch -m [old branch] [new branch]

Deleting a branch

$ git branch -m [old branch] [new branch]

Switching branches

Go to: Checkout

Merging branches

$ git merge [branch]




Back to the top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment