# Git important commands

**Git Commands :**

Set global user name

```plaintext
git config -global user.name "user name"
```

Set global user email

```plaintext
git config --global user.email "email" 
```

Initialize repository

```plaintext
git init
```

Clone repository

```plaintext
git clone <repo_url>
```

View repository status

```plaintext
git status
```

Stage changes

```plaintext
git add
```

Stage all changes

```plaintext
git add .
```

Create branch

```plaintext
git branch <branch_name>
```

Commit changes

```plaintext
git commit -m "message"
```

List branch

```plaintext
git branch -a
```

Switch to branch

```plaintext
git checkout <branch name>
```

Merge branch

```plaintext
git merge <branch name>
```

Pull changes

```plaintext
git pull origin <branch name>
```

Push changes

```plaintext
git push origin <branch name>
```

View commit history

```plaintext
git log
```

Revert commit

```plaintext
git revert
```

Reset to commit

```plaintext
git reset
```

List tags

```plaintext
git tag
```

Show changes not yet staged

```plaintext
git diff
```

Add remote repository

```plaintext
git remote add origin <repo_url>
```

Show remote details

```plaintext
git remote show origin
```

Delete untracked files

```plaintext
git clean -f 
```

Interactive rebase

```plaintext
git rebase i
```
