| π Git Basics | |
git init | Initialize a new Git repository. |
git clone <repository-url> | Clone an existing repository from a remote source. |
git status | Show the current status of the working directory and staging area. |
git add <file> | Stage a file for the next commit. |
git add . | Stage all changes in the current directory. |
git commit -m "<message>" | Commit staged changes with a message. |
git log | View the commit history. |
git diff | Show changes between commits, the working tree, and the index. |
| π Branching | |
git branch | List all branches in the repository. |
git branch <branch-name> | Create a new branch. |
git checkout <branch-name> | Switch to a specified branch. |
git checkout -b <branch-name> | Create and switch to a new branch. |
git merge <branch-name> | Merge the specified branch into the current branch. |
git branch -d <branch-name> | Delete a specified branch. |
| π Remote Repositories | |
git remote -v | List all configured remote repositories. |
git remote add <name> <url> | Add a new remote repository. |
git fetch <remote> | Fetch changes from a remote repository without merging. |
git pull <remote> <branch> | Fetch and merge changes from a remote branch. |
git push <remote> <branch> | Push local changes to a remote repository. |
| π§ Stashing Changes | |
git stash | Stash the current changes in a temporary storage. |
git stash list | List all stashed changes. |
git stash apply | Apply the most recent stash. |
git stash pop | Apply the most recent stash and remove it from the stash list. |
| π Viewing Changes | |
git show <commit> | Show changes made in a specific commit. |
git blame <file> | Show what revision and author last modified each line of a file. |
| π Tagging | |
git tag | List all tags in the repository. |
git tag <tag-name> | Create a new tag for the current commit. |
git push origin <tag-name> | Push a specific tag to the remote repository. |
| π Configuration | |
git config --global user.name "<name>" | Set the global username for Git commits. |
git config --global user.email "<email>" | Set the global email for Git commits. |
git config --global core.editor <editor> | Set the default text editor for Git. |