Introduction
Git, the powerful version control system, is a must-know for developers and teams collaborating on projects. In this guide, we'll explore essential Git commands, GitHub usage, and best practices to streamline your development workflow.
Getting Started with Git
Configuring User Information
git config --global user.name "Your Name"
Checking Configuration
git config --list
Initializing a Git Repository
git init
Basic Git Commands
Checking Repository Status
git status
Adding and Committing Changes
git add . git commit -m "Your commit message"
Viewing Commit History
git log
Navigating and Undoing Changes
Changing Directories
cd <directory>
Ignoring Files Create a
.gitignore
file and list files or directories to be ignored.Comparing Changes
git diff
Undoing Changes
git restore --staged <file> git checkout -- <file>
Branching in Git
Viewing and Creating Branches
git branch git branch <branch-name>
Switching Between Branches
git checkout <branch-name>
Deleting Branches
git branch -d <branch-name>
GitHub Integration
Cloning a Repository
git clone <repository-link>
Pushing Changes to GitHub
git push origin <branch-name>
Deleting Remote Branches
git push -d origin <branch-name>
GitHub Configuration
Linking a Local Repository to GitHub
git remote add origin <repository-link>
Creating SSH Keys for GitHub GitHub SSH Key Guide
Removing a Git Repository
rm -rf .git
Additional Tips
Copy-Paste Shortcuts
Shift + Insert
: Paste anything in the terminal.
Checking Present Working Directory
pwd
Log Navigation After
git log
, pressq + enter
to exit.Ignoring Files Permanently Use
.gitignore
to list files/folders to be ignored.Pushing Without Staging
git add -A -m "Your commit message"
Renaming and Deleting Files
git rm <file-name> git mv <old-name> <new-name>
Log with Statistics
git log --stats
Log Formatting
git log --pretty=oneline
Log Filtering by Date
git log --since=2.days
Checking Remote Repositories
git remote -v
Matching Working Directory
git checkout -f
Conclusion
Mastering these Git commands and GitHub practices will empower you to efficiently manage your projects and collaborate seamlessly. Remember, practice is key to becoming a Git expert!
Thank you so much for considering my message. I understand your time is valuable, and any guidance you can provide would be immensely helpful.