Github Commands Cheat Sheet



  1. Git Commands Cheat Sheet Github
  2. Github Command Line Cheat Sheet
  3. Github Commands Cheat Sheet 2020
  4. Github Commands Cheat Sheet
  5. Github Git Cheat Sheet

This cheat sheet-style guide provides a quick reference to commands that are useful for working and collaborating in a Git repository. To install and configure Git, be sure to read “How To Contribute to Open Source: Getting Started with Git.” How to Use This Guide: This guide is in cheat sheet format with self-contained command-line snippets. A cheat sheet for VisiData commands. Advanced row selection + regex Select all rows where regex matches the current column + regex Unselect all rows where regex matches the current column. Git Cheat Sheet Create From existing repo From existing data cd /projects/myproject git init git add. Git clone /existing/repo /new/repo git clone git://host.org.

If you have ever worked in web development or in any Software development, then you must have heard of Git, or most probably you have used or using git because it is one of the best version control systems we have. The website GitHub use git version control as its brain. Git provides the best way to manage your project, and it became more helpful when a proper team is working on a project.

Git comes with a standard Command Line Interface (CLI), which mean to interact or work with Git we need to pass commands, though if we are using GitHub for our project rather than using git commands we simply use GitHub buttons and other option to manage our project but it is not necessary that if we are using Git we are using GitHub too, Git and GitHub are two separate entities. Many Developers find using a CLI intriguing because it makes them happy to interact with command lines or terminal or white text on black console, but for a beginner using a command line for git commands becomes a daunting task. Git contains hundreds of commands and it is impossible to learn each of them, so what we do, we just simply learn and practice only those commands which are common and enough to serve our purpose.

So here we have provided a cheat sheet for Git commands, so, you could muddle through if you get stuck somewhere using git or forget some commands.

What is Git?

Git is an open-source distributed version control system and the working principle behind the GitHub website. It is the most famous and widely used version control system of this decade which has huge community support. It is called the Distributed Version control system because, unlike other version control systems that store the project’s full version history in one place, Git allows each developer to have their own local repository with complete proper history changes.

What is Version Control?

A version control system is a software that keeps track of your project history and version.

Git Terminologies

Before reading the git cheat sheet let’s have the look at the basic terminologies we use in git:

TerminologyDescription
BranchA branch represents the various versions and repositories branching out from your main project. It helps us to keep track of the changes happening in the various repositories.
CommitCommit is used to save some changes.
CheckoutWhen we switch between branches we use checkout command.
FetchFetch commands can copy and download the branch file to your local device.
ForkA fork is a copy of a repository.
HeadThe commit at the tip of a branch is called the head. It represents the most current commit of the repository you’re currently working in
IndexIf we make any changes in the project in order to save those changes we need to commit them, if not all those changes will remain in the index for commit.
MasterThe main branch of the repositories.
MergeIf one branch made any changes so, we can use the merge command to make that same changes in all other repositories
OriginThe default version of a repository
PullIt represents the suggestion for changes to the master branch
PushIt is used to update the remote branch if we have committed the changes
RepositoryIt holds all the project’s files
TagIt tracks the important commits

Git Cheat Sheet

Git Commands Cheat Sheet Github

Git Configuration

CommandsDescription
git config –-global user.name “User Name”Attach the name User Name to the commits and tag
git config –global user.email “email address”Attach the email address to the commits and tags
git config –global color.ui autoEnable some colorization in Git interface

Git Setting Project

CommandsDescription
git init [project name]This command will create a new repository if the project name is provided else it will initialize the git in the current directory.
git clone [project url]It will create a clone of the project which is at remote repository project URL

Git Frequent used commands

CommandsDescription
git statusShow the status of the repository
git diff [File]Show changes between the working directory and staging area
git diff –stages [file]Show changes between the staging area and index
git checkout — [file]Discard change in the working directory
git add [file]Add new file
git reset [file]Get the file back from the staging area
git commitSave the changes
git rm [file]Remove the file
git stashPut the changes into stash

Git Branching

CommandsDescription
git branch [-a]It will show all the branches of the local repository her –a mean all
git branch [branchname]Create a new branch
git checkout [-b] [name]Switch to name branch, if name is not a branch in the repository so create new branch.
git merge [branch]Merge the branch
git branch –d [branch name]Remove the branch

Review Work

CommandsDescription
git log [-n count]List last n numbers of commit history
git log –oneline –graph –decorateGive Overview along with reference label and history graph.
git log ref. .List current branch commits
git reflogList operations such as commits, checkout, etc.

Git Tag

CommandsDescription
git tagShow all tags
git tag [name] [commit sha]Create a tag reference named name for current commit
git tag –d [name]Remove the tag

Revert Changes

CommandsDescription
git reset [–hard] [target reference]Switch current branch to the target reference, and leaves a difference as an uncommitted change.
git revert [commit sha]Create a new commit, reverting changes from the specified commit.

Synchronizing Repositories

CommandsDescription
git fetch [remote]Fetch the changes from remote
git pull [remote]Fetch the changes and merge the current branch with upstream
git push [remote]Push all the changes to the remote
git push –u [remote] [branch]Push the local branch to the remote upstream

Conclusion

Git has hundreds of commands and to learn each command is impossible so we only use those commands which are basic and necessary for our project point of view. All the git commands we have provided in this article are the most important git commands and every interviewer expects, you to know at least these commands.

If you like this article or have any suggestion related to the git cheat sheet, please let us know by filling the comment box.

You may be also interested in:

Create repositories

A new repository can either be created locally, or an existing repository can be cloned. When a repository was initialized locally, you have to push it to GitHub afterwards.

$ git init

Cheat

The git init command turns an existing directory into a new Git repository inside the folder you are running this command. After using the git init command, link the local repository to an empty GitHub repository using the following command:

$ git remote add origin [url]

Specifies the remote repository for your local repository. The url points to a repository on GitHub.

$ git clone [url]

Github Command Line Cheat Sheet

Github Commands Cheat Sheet

Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits

The .gitignore file

Sometimes it may be a good idea to exclude files from being tracked with Git. This is typically done in a special file named .gitignore. You can find helpful templates for .gitignore files at github.com/github/gitignore.

Synchronize changes

Pdf

Synchronize your local repository with the remote repository on GitHub.com

$ git fetch

Github Commands Cheat Sheet 2020

Downloads all history from the remote tracking branches

$ git merge

Combines remote tracking branches into current local branch

$ git push

Uploads all local branch commits to GitHub

Github tutorial pdf

Github Commands Cheat Sheet

$ git pull

Github Git Cheat Sheet

Updates your current local working branch with all new commits from the corresponding remote branch on GitHub. git pull is a combination of git fetch and git merge