Git Cheat Sheet

Git Cheat Sheet

What is Git?

A Git is a developer tool used for tracking code changes, tracking who made changes, and collaborating on code. It is a popular version control system. It was created by Linus Torvalds in 2005 and has been maintained by Junio Hamano.

Git function

Git is a free and open-source VCS (Version Control System), which means it's a way to keep track of every change in your software. If you are working on a project over time, you may want to keep track of which changes were made, by whom, and when those changes were made. This becomes increasingly important if you end up having a bug in your code! Git can help you with this.

Git installation process

Step 1: Windows: [Download] (gitforwindows.org) Step 2: Once you follow these steps, run the following command to check if Git is installed correctly:

git --version

The above command will display the latest version.

Step3: We are ready to go!!!

Now we move on to check git commands:

Git Commands

There are lots of commands to use in the Git system, but we will learn some basic ones. like for pushing the repo from local to remote, branching and merging, etc.

1. Commands we use when we need to push a local repository to a remote repository.

  • git config: Used to set configs after Git installation.
  • git init: Create an empty Git repo in the specified directory.
  • git add: Stage all changes in the directory for the next commit.
  • git commit -m "message": Used to add the documents to be added to the local repository with comments.
  • git remote: This command is used to connect your local repository to the remote server.
  • git push: Push all of your local branches to the specified remote.

2. Commands we use when multiple people are working on the same projects.

  • git branch: List all of the branches in your repo. Add a argument to create a new branch with the name .
  • git checkout: Create and check out a new branch named . Drop the -b flag to checkout an existing branch.
  • git merge: Merge into the current branch.

3. Commands to use when we want to copy a project from the remote repository to our computer and undo the changes after committing the documents.

  • git clone: Clone repo located at onto local machine.
  • git revert: Create a new commit that undoes all of the changes made in , then apply it to the current branch.
  • git reset: Remove from the staging area, but leave the working directory unchanged. This unstaged a file without overwriting any changes.
  • git clean: Shows which files would be removed from the working directory.

Arigato!!!✌