dev-resources.site
for different kinds of informations.
Essential Git Commands Every Developer Should Know
Published at
12/26/2024
Categories
gitcommands
versioncontrol
gittutorial
gitforbeginners
Author
abhay_yt_52a8e72b213be229
Author
25 person written this
abhay_yt_52a8e72b213be229
open
Essential Git Commands
Here’s a list of commonly used Git commands, categorized for convenience:
1. Setup and Configuration
- Check Git Version:
git --version
- Configure Username:
git config --global user.name "Your Name"
- Configure Email:
git config --global user.email "[email protected]"
- View Configuration:
git config --list
2. Repository Management
- Initialize a Repository:
git init
- Clone a Repository:
git clone <repository-url>
- View Repository Status:
git status
3. Working with Files
- Add Files to Staging Area:
git add <file> # Add a specific file
git add . # Add all changes in the current directory
- Commit Changes:
git commit -m "Your commit message"
- Remove Files:
git rm <file>
- Move/Rename Files:
git mv <old_filename> <new_filename>
4. Branching and Merging
- Create a New Branch:
git branch <branch-name>
- Switch to a Branch:
git checkout <branch-name>
- Create and Switch to a New Branch:
git checkout -b <branch-name>
- Merge a Branch:
git merge <branch-name>
- Delete a Branch:
git branch -d <branch-name>
5. Remote Repositories
- Add a Remote Repository:
git remote add origin <repository-url>
- View Remote Repositories:
git remote -v
- Push Changes to Remote Repository:
git push origin <branch-name>
- Pull Changes from Remote Repository:
git pull origin <branch-name>
- Fetch Changes from Remote:
git fetch
6. Viewing and Inspecting
- View Commit History:
git log
- View a Specific Commit:
git show <commit-hash>
- View Changes in Files:
git diff
- View Changes in Staged Files:
git diff --staged
- List Branches:
git branch
7. Undo Changes
- Unstage Files:
git reset <file>
- Undo Last Commit (Keep Changes):
git reset --soft HEAD~1
- Undo Last Commit (Discard Changes):
git reset --hard HEAD~1
- Discard Unstaged Changes:
git checkout -- <file>
8. Stashing
- Save Changes Temporarily:
git stash
- Apply Stashed Changes:
git stash apply
- List Stashes:
git stash list
- Drop a Stash:
git stash drop
9. Tags
- Create a Tag:
git tag <tag-name>
- List Tags:
git tag
- Push Tags to Remote:
git push origin <tag-name>
10. Collaboration
- Rebase:
git rebase <branch-name>
- Cherry-pick a Commit:
git cherry-pick <commit-hash>
-
Resolve Merge Conflicts:
- Edit conflicting files manually.
- Stage resolved files:
git add <file>
- Complete the merge:
git commit
These commands cover most Git functionalities for beginners and intermediate users. If you need clarification or advanced commands, feel free to ask! 😊
gitcommands Article's
20 articles in total
Git Commands Every Developer Must Know 🔥
read article
A Comprehensive Guide to All Git Commands for Every Developer
read article
Essential Git Commands Every Developer Should Know
currently reading
Git Commands for Test Automation: Best Practices and Advanced Techniques
read article
Git - Useful Commands
read article
7 BASIC GIT COMMANDS
read article
Most commonly used Git command shortcuts
read article
Git Basics: Git Commands and How to Use Them
read article
Git Basics: A Guide to Efficient Version Control and Collaborative Development
read article
Push your code to remote repo - Getting Started with Git Basics 2
read article
Getting Started with Git Basics
read article
Some less popular git commands
read article
Hacks e boas práticas de git
read article
Git Comfortable
read article
Basic Git Commands
read article
Git surgery #1
read article
Git Cheat Sheet
read article
My Git Hot Commands
read article
Getting started with Git? 10 commands that would save you…
read article
Find the right git commands without digging through the web
read article
Featured ones: