12 Essential Git Commands for Developers

Here are 12 must-know Git commands with quick explanations and examples: • git init: Initializes a new Git repository in your current directory. • Example: $ git init • git add: Stages changes (files/directories) for the next commit. • Example: $ git add app.css • git commit: Records the staged changes with a commit message. • Example: $ git commit -m "Initial commit" • git push: Uploads your local changes to a remote repository (e.g., GitHub). • Example: $ git push origin main • git pull: Fetches and merges changes from the remote repository into your local branch. • Example: $ git pull origin main • git remote: Manages the remote repositories connected to your project. • Example: $ git remote add origin <url> • git branch: Lists, creates, or deletes branches. • Example: $ git branch feature-login • git fetch: Retrieves the latest data from the remote repo but doesn't integrate it into your working files (unlike git pull). • Example: $ git fetch origin • git checkout: Switches between branches or restores working tree files. • Example: $ git checkout feature-login • git merge: Combines the specified branch into your current branch. • Example: $ git merge feature-login • git status: Displays the state of your working directory and staging area. Essential for checking uncommitted changes! • Example: $ git status • git reset: Undoes changes. Resets the current branch to a specified commit. • Example: $ git reset --hard <commit-hash> Which Git command do you use the most? Share your favorite tip below! 👇 #Git #Developer #Coding #VersionControl #Programming #TechTips #SoftwareDevelopment #Backend #TechTips #Coding #DevCommunity #AdarshMurali

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories