Most Used Git Commands-
Setting User Name
git config --global user.name "Sandeep Kumar"
git config --global --replace-all user.name "Sandeep Kumar"
Setting Email
git config --global user.email "sandeep.saini482@gmail.com"
Setting Code Editor
git config --global code.editor "nano"
To see global git configuration
git config --list
Creates a brand new Git repository.
git init
Adding a remote repository
git remote add origin {master branch url}
To check all the branches
git remote -v
To check what branch we are currently on
git branch --v
To check status of current working branch
git status
To stage specific file
git add index.html
To stage all files
git add .
Commit with message
git commit -m 'CR4059 Changes'
First Time Push
git push -u -f origin master
create a branch based on master branch locally
git checkout -b test-branch master
to save branch on server
git push --set-upstream origin test-branch
switch to master branch
git checkout master
fetch all changes from remote
git fetch --all
list of all branches from remote
git branch -r
delete branch on remote
git push -d origin feature/created-online
delete branch locally
git branch -d test-branch
to get commits done with id
git log --oneline
to revert change change upto below commit id
git revert {commitId}
push is needed after revert
git push