Commonly used Git Commands in Github

edited May 2023 in General

Git it is an open-source distributed version control system.

The basic GIT commands are as follows:

 It is used to set the name of the author and the email address which you want your commitment to addressing.

git config –global user.email “[email address]”

 git init:

  • It is used to start a new git repository. This is generally used at the beginning.
  • git init [repo name]

git clone:

This command is used to clone or copy a repository from a URL. This URL generally is a bitbucket server, a stash or any other version control and source code management repository holding service.

git clone [url]

git add:

It is used to add a file to the staging area. Instead of choosing a single file name, you can also choose to give all filenames with an *.

git add (filename),

git add *

git commit –m:

 It is used to snapshot or record a file in its version history permanently.

git commit –m [type in a message]

Branch:

branch is a copy of the files in the repository at the time you create the branch. You can work in your branch without affecting other branches. When you’re ready to add your changes to the main codebase, you can merge your branch into the default branch.

Create a branch:

To create a feature branch:

git checkout -b <name-of-branch>

Switch to a branch:

All work in Git is done in a branch. You can switch between branches to see the state of the files and work in that branch.

To switch to an existing branch:

git checkout <name-of-branch>

git status:

The status command is used to display the state of the working directory and the staging area. It allows you to see which changes have been staged, which haven't, and which files being tracked by Git.

git push:

It is used to upload local repository content to a remote repository. Pushing is an act of transfer commits from your local repository to a remote repo.

$ git push

git pull:

Pull command is used to receive data from GitHub. It fetches and merges changes on the remote server to your working directory.

$ git pull:


Sign In or Register to comment.