Tuesday, December 14, 2021

Basic Git Commands cheat sheet

 

git config

Syntax: git config –global user.name “[name]”

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

This command sets the author name and email address respectively to be used with your commits.

git init

Syntax: git init [repository name]

This command is used to start a new repository.

git add

Syntax: git add [file]

This command adds a file to the staging area.

Syntax: git add *

This command adds one or more to the staging area.

git clone

Syntax: git clone [url]

This command is used to obtain a repository from an existing URL.

git commit

Syntax: git commit -m “[ Type any commit message of your choice]”

This will record or snapshot the file permanently in the version history.

Syntax: git commit -a

This will commit any files you’ve added with the git add command and also will commit any files you’ve changed since then.

git reset

Syntax: git reset [file]

This command unstages the file, but it saves/preserves the file contents.

Syntax: git reset [commit]

This command undoes all the commits after the specified commit and preserves the changes locally.

Syntax: git reset –hard [commit]

This command discards all history and goes back to the specified commit.

git status

Syntax: git status

This command lists all the files that have to be committed.

git show

Syntax: git show [commit]

This command shows the metadata and content changes of the specified commit.

git branch

Syntax: git branch

This command lists all the local branches in the current repository.

Syntax: git branch [branch name]

This command creates a new branch.

Syntax: git branch -d [branch name]

This command deletes the feature branch.

git checkout

Syntax: git checkout [branch name]

This command is used to switch from one branch to another.

Syntax: git checkout -b [branch name]

This command creates a new branch and also switches to it.

git remote

Syntax: git remote add [variable name] [Remote Server Link]

This command is used to connect your local repository to the remote server.

git push

Syntax: git push [variable name] master

This command sends the committed changes of master branch to your remote repository.

Syntax: git push [variable name] [branch]

This command sends the branch commits to your remote repository.

Syntax: git push –all [variable name]

This command pushes all branches to your remote repository.

Syntax: git push [variable name] :[branch name]

This command deletes a branch on your remote repository.

git pull

Syntax:  git pull [Repository Link]

This command fetches and merges changes on the remote server to your working directory.

git tag

Syntax: git tag [commitID]

This command is used to give tags to the specified commit.

git merge

Syntax: git merge [branch name]

This command merges the specified branch’s history into the current branch.

No comments:

Post a Comment

Clustering in Machine Learning

Clustering is a type of unsupervised learning in machine learning where the goal is to group a set of objects in such a way that objects in...