Essential Git Commands
Discover the essential Git commands for managing your projects.
I
InSkillCoach
· min
Essential Git Commands
Discover the essential Git commands for managing your projects.
Initial Setup
# Configure your identity
git config --global user.name "Votre Nom"
git config --global user.email "votre.email@exemple.com"
# Create a new repository
git init
# Clone an existing repository
git clone <url_du_depot>
Basic Commands
File Management
# Check the repository status
git status
# Add files
git add <fichier>
git add . # Add all files
# Create a commit
git commit -m "Description du commit"
# View the history
git log
git log --oneline
git log --graph
Branch Management
# Create a new branch
git branch <nom_branche>
git checkout -b <nom_branche> # Create and switch
# Switch branches
git checkout <nom_branche>
# Merge branches
git merge <branche_source>
git rebase <branche_source>
# Delete a branch
git branch -d <nom_branche>
Working with a Remote Repository
# Add a remote repository
git remote add origin <url_depot>
# Push changes
git push origin <branche>
# Fetch changes
git fetch
git pull
# View remote repositories
git remote -v
Conflict Management
# View conflicts
git status
# Resolve conflicts
# 1. Open the conflicting files
# 2. Choose which changes to keep
# 3. Add the resolved files
git add <fichier>
# Finalize the resolution
git commit -m "Résolution des conflits"
Advanced Commands
Change Management
# Discard uncommitted changes
git checkout -- <fichier>
# Undo the last commit
git reset HEAD~1
# Modify the last commit
git commit --amend
# Stash changes
git stash
git stash pop
Tag Management
# Create a tag
git tag -a v1.0 -m "Version 1.0"
# Push tags
git push origin --tags
Best Practices
-
Commits
- Clear, descriptive messages
- One commit per feature
- Atomic commits
- Review before committing
-
Branches
- Stable main branch
- Feature branches
- Bugfix branches
- Regular cleanup
-
Workflow
- Pull before push
- Test before committing
- Code review
- Documentation
Conclusion
Key takeaways:
- Essential basic commands
- Branch management
- Collaborative work
- Conflict resolution
Recommendations:
- Practice regularly
- Follow conventions
- Document your changes
- Use best practices
- Keep learning Git
About InSkillCoach
Training and technology expert
Coach specializing in advanced technologies and AI, backed by GNeurone Inc.
Certifications:
- AWS Certified Solutions Architect – Professional
- Google Cloud certifications
- Microsoft Certified: DevOps Engineer Expert
- Certified Kubernetes Administrator (CKA)
- CompTIA Security+
1.9k
332
Comments
Comments are powered by GitHub Discussions
Sign in with GitHub to join the discussion