Git important commands

Git important commands

Git Commands :

Set global user name

git config -global user.name "user name"

Set global user email

git config --global user.email "email"

Initialize repository

git init

Clone repository

git clone <repo_url>

View repository status

git status

Stage changes

git add

Stage all changes

git add .

Create branch

git branch <branch_name>

Commit changes

git commit -m "message"

List branch

git branch -a

Switch to branch

git checkout <branch name>

Merge branch

git merge <branch name>

Pull changes

git pull origin <branch name>

Push changes

git push origin <branch name>

View commit history

git log

Revert commit

git revert

Reset to commit

git reset

List tags

git tag

Show changes not yet staged

git diff

Add remote repository

git remote add origin <repo_url>

Show remote details

git remote show origin

Delete untracked files

git clean -f

Interactive rebase

git rebase i