is one of the most popular Version Control Systems out there, you can think of it as a way to take snapshots ( in Git nomenclature) of your code in a specific state and time, just in case you mess things up later and want to go back to a stable version of your code. It’s also a great way to collaborate if you combine it with . Git commits GitHub Git is free and open source. You can download it from the . Once it’s installed you should be able to run Git commands on your terminal. official website A couple of things you should know before starting to use Git: When you want to keep track of the files in a project you put them inside a . A repository is basically a directory in which version control is enabled and always vigilant of what you put in there. It will know whenever any changes are made to those files, and it will help you keep track of them. repository Each commit has an identifier in case you need to reference it later, this ID is called and it’s as string of characters. SHA A contains all the files you see on your project directory. working directory The is a file in the Git directory that stores the information about what is going to be included in your next commit.Create or Clone a repository staging index Create or Clone a repository Create or clone a repository on the current directory. Create repository from scratch: git init Clone an existing repository: git clone <https://github.com/>... Clone repository and use different name: git clone <https://github.com/>... new_name Display information Determine a Repo’s status: git status Display a Repo’s commits: git log Display a Repo’s commits in a compact way: git log --oneline Viewing Modified Files: git log --stat Viewing file changes: git log -p Viewing file changes ignoring whitespace changes: git log -p -w Viewing most recent Commit: git showViewing A Specific Commit: git show <SHA of commit> Add “Staging” means moving a file from the Working Directory to the Staging Index. Staging Files: git add <file1> <file2> … <fileN> Unstaging files: git rm --cached <file>... Stage all the files: git add . Commit Take files from the Staging Index and save them in the repository. Commit staged files: git commit This command will open the code editor. Inside the code editor you must supply a commit message, save the file and close the editor. Commit files without opening the code editor: git commit -m "Commit message" Git Diff See changes that have been made but haven’t been committed yet: git diff Tagging Tags are used as markers on specific commits. These are really useful to assign a version to the code. Add tag to the most recent commit: git tag -a <tag(v1.0)> Add tag to specific commit: git tag -a <tag(v1.0)> <SHA of commit> -a is used to create an annotated tag, which includes extra information such as the date of creation and the person who made it. It is usually considered a good practice to add this flag. Display all tags in the repository: git tag Deleting A Tag: git tag -d <tag-name> Branching When a commit is made in a repository it’s added to the branch you’re currently on. By default a repository has a branch called Specially when experimenting with new features on your code, it is often useful to create a separate branch that acts as a safe isolated environment from your last commit. You can switch between branches and the commits will only be added to the one you’re currently on. master. List all branches: git branch Create new branch: git branch <branch-name> Delete branch: git branch -d <branch-name> You cannot delete a branch you’re currently on. You cannot delete a branch if it contains any commits that aren’t on any other branch. To force deletion: git branch -D <branch-name> Switch between branches: git checkout <branch-name> Add branch on a specific commit: git branch <branch-name> <SHA of commit> Start branch at the same location as the master branch: git branch <branch-name> master See all banches at once: git log --oneline --decorate --graph --all Merging When a merge is performed, the other branch’s changes are brought into the branch that’s currently checked out. Perform merge: git merge <branch to merge in> Correcting stuff Modify last commit message: git commit --amend Revert a commit This will create a new commit that reverts or undos a previous commit. Undo the changes made in a commit: git revert <SHA of commit> Reset a commit This will erase commits. Reset commit: git reset <reference to commit> Depending on the flag you add you’ll obtain a different result: flag to erase commits --hard flag to move the committed changes to the staging index --soft flag to unstage committed changes --mixed If you want to learn more about Git, Udacity offers that covers all the basics and many more concepts in depth (for free!). I did this course myself and it served as an inspiration to make this summary about some of the main concepts I learned and now use in my projects. this great course Hope you got some value from this post 😊 see you in the next one! Previously published at https://medium.com/@elsascola/the-git-cheat-sheet-5858865457ef