Git
Git
A handy reference for commonly used Git commands with concise explanations.
Configuration Commands
1. Set Username
git config --global user.name"Your Name"
2. Set Email
git config --global user.email "[email protected]"
3. Check Configuration
git config --list
Repository Commands
4. Initialize a Repository
git init
5. Clone a Repository
git clone <repository-url>
Staging Commands
6. Add Specific File
git add <file>
Stages all new, modified, and deleted files in the current directory.
Lists all branches in the repository and highlights the current branch.
Commit Commands
15. Commit Changes
git commit -m "Your commit message"
Remote Repositories
17. Add a Remote Repository
git remote add origin <repository-url>
Sends commits from your local branch to the corresponding remote branch.
Fetches updates from the remote branch and merges them into your current branch.
Miscellaneous
21. Discard Unstaged Changes
git checkout -- <file>
Reverts unstaged changes to the last committed state.
Resets the repository to a specific commit, discarding all changes after it.
Displays differences between the working directory and the staging area.