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! π
versioncontrol Article's
30 articles in total
Do You Care About Commit Messages?
read article
GitHub vs. GitLab vs. Bitbucket
read article
Git Hosting Services: A Comparison of GitHub, GitLab, Bitbucket, and Azure Repos
read article
Mastering Git Repositories: Initialization, Cloning, Remotes, URLs, and Submodules
read article
A Comprehensive Guide to All Git Commands for Every Developer
read article
Committing Changes in Git: A Complete Guide to Git Add, Commit, Messages, and Amending
read article
Mastering Git Branching and Merging: A Complete Guide to Git Branches, Merge, Rebase, and More
read article
Git Tags
read article
Essential Git Commands Every Developer Should Know
currently reading
Master Git: A Comprehensive Beginner to Advanced Guide
read article
Understanding Git: The Ultimate Guide with Practical Examples
read article
.git
read article
Code Like a Librarian: A Beginner's Guide to Git and GitHub
read article
Version Control with Git: How to Master It - Best Practices for Efficient Code Management by Git
read article
A Beginnerβs Guide to GitHub
read article
Effective Git Workflow: Managing Version Control in Team Environments
read article
ππ²π©ππ¬ π¨π πππ«π¬π’π¨π§ ππ¨π§ππ«π¨π₯ ππ²π¬πππ¦π¬:
read article
Azure DevOps Series - Azure Repos
read article
Mastering DevOps Branching: Your Ultimate Guide to Git Flow, Trunk, Tag-Based, and Hybrid Strategies
read article
Ultimate Git Basics Cheatsheet [Live Doc]
read article
Understanding the Role of Git Tags in Version Control
read article
Git - Useful Commands
read article
Version Control and Git: Essential Tools for Modern Software Development
read article
Ultimate Git Branches & Merging Cheatsheet [Live Doc]
read article
Git and GitHub for Beginners: A Comprehensive Step-by-Step Guide
read article
Bagaimana cara memindahkan branch utama git dari master menjadi main
read article
Version Control with Git and GitHub: The Importance and Effective Usage
read article
A Comprehensive Guide to Using Footers in Conventional Commit Messages
read article
Version Control Best Practices with Git and GitHub
read article
Using interactive rebase in Git
read article
Featured ones: