Linux, DevOps and Cloud Expert at Linux Guru !

Git Commands

image courtesy git-scm


Here are some git command list which are comes in daily use.

Creating and Cloning:

commands
use
git init
create and initialize local git repository
git clone REPO_URL
Clone remore repo
git remote add origin REPO_URL
add remote repository.
git config-global user.name my-name
set author name
git config-global user.email my-email
set author email

Basic git commands : 

commands
use
git status
check the current state of repository
git add .
Add all the files to staging area repository
git add vishal.txt
add perticular file to the staging area repository
git commit -m "commit message"
commit files
git pull
pull the latest code from repo
git pull origin remote-branch
pull the latest code from the remote branch
git push
remember branch push
git push -u origin branch_name
push code to the remote branch
git diff branch1 branch2
show different between two branches befor merge
git stash
save the work and clean the working directory
git rm -f
delete a file
git log
show the entire git log

Create branch and merging : 

commands
use
git branch branch_name
create a branch
git branch
list branch in local repository
git branch -a
list all branches from remote and local
git branch -d my_branch
delete local branch
git push origin --delete my_branch
delete branch from remote repo
git checkout -b my_branch
create new branch and switch to the branch
git merge branch_name
merge branch to the current
git merge my_branch target_branch
merge branch to source to target branch

No comments:

Post a Comment