Top 10 Git Commands Every Developer Should Know

on

|

views

and

comments

Table of Contents

Git config commands

Essential Git Commands with Examples to Streamline Your Version Control Workflow:

Git config commands are used to configure Git on your local machine. Here are some commonly used Git config commands with examples:

				
					git config --global user.name "Your Name"
				
			

git config –global user.name “Your Name”: Sets the name associated with your Git commits. Example: `git config –global user.name “John Doe”`

				
					git config --global user.email "your_email@example.com"
				
			

git config –global user.email “your_email@example.com”: Sets the email address will be associated with your Git commits and will appear the UI of the systems like GitHub, GitLab and etc.. Example: `git config –global user.email “johndoe@example.com”`

Git Essential Commands

				
					git init
				
			

git init: Initializes a new Git repository on your local machine, allowing you to start tracking changes to your code.

Example: `git init my_project`

				
					git clone
				
			

git clone: Creates a local copy of a remote repository, making it easy to collaborate with others on a project.

Example: `git clone https://github.com/user/repo.git`

				
					git add
				
			

git add: Adds changes to the staging area, allowing you to review and prepare them for committing.

Example: `git add file.txt`

				
					git commit
				
			

git commit: Commits changes to the repository with a message describing the changes, helping you keep track of what you’ve done.

Example: `git commit -m “Added new feature”`

				
					git push
				
			

git push: Pushes changes to a remote repository, making sharing your work with others easy.

Example: `git push origin master`

				
					git pull
				
			

git pull: Fetches changes from a remote repository and merges them with your local copy, keeping your code up-to-date.

Example: `git pull origin master`

				
					git branch
				
			

git branch: Lists all branches in the repository or creates a new branch, allowing you to work on multiple features simultaneously.

Example: `git branch new_feature`

				
					git checkout
				
			

git checkout: Switches to a different branch or restores a file from an earlier commit, making navigating your code history easy.

Example: `git checkout new_feature`

				
					git merge
				
			

git merge: Merges changes from one branch into another, helping you combine different features or bug fixes.

Example: `git merge new_feature`

				
					git status
				
			

git status: This command will show the status of your working directory and staging area, giving you an overview of what changes have been made and what still needs to be committed.

Example: `git status`”

Git remote commands

Git remote commands are used to manage connections to remote repositories. Here are some commonly used Git remote commands with examples:

				
					git remote add origin
				
			

git remote add origin https://github.com/user/repo.git: Adds a remote repository to your local repository, allowing you to push and pull changes.

Example: `git remote add origin https://github.com/user/repo.git

				
					git remote -v
				
			

git remote -v: Lists all the remote repositories associated with your local repository.

Example: `git remote -v`

				
					git remote show [remote_name]
				
			

git remote show [remote_name]: Displays information about a specific remote repository.

Example: `git remote show origin`

				
					git remote rename [old_name] [new_name]
				
			

git remote rename [old_name] [new_name]: Renames a remote repository.

Example: `git remote rename origin github`

				
					git remote remove [remote_name]
				
			

git remote remove [remote_name]: Remove a remote repository from your local one.

Example: `git remote remove github`

These are just a few examples of Git remote commands. There are many more options available for managing your remote repositories.

https://www.pantherschools.com/the-power-of-devops-how-collaboration-and-automation-drive-faster-software-delivery-and-improved-business-outcomes/

Download Software

You can download Git from the official website: https://git-scm.com/downloads

On this page, you will find links to download Git for Windows, Mac, and Linux. Select the appropriate OS for your operating system, and follow the installation instructions.

Once you have downloaded and installed Git, you can manage your version control workflows. Don’t forget to check out the official Git documentation for more information on how to use Git effectively.

Git Cheat Sheat

Here are some links to Git cheat sheets that you may find helpful:

  1. Atlassian Git Cheat Sheet: [https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet]
  2. GitHub Git Cheat Sheet: [https://education.github.com/git-cheat-sheet-education.pdf]
  3. GitLab Git Cheat Sheet: [https://about.gitlab.com/images/press/git-cheat-sheet.pdf]
  4. Git Tower Git Cheat Sheet: [https://www.git-tower.com/blog/git-cheat-sheet/]
  5. GitKraken Git Cheat Sheet: [https://www.gitkraken.com/resources/git-cheat-sheet]

Each cheat sheet provides a quick reference guide to Git commands and workflows, making it easy to get up and running with Git.

Whether you’re an experienced Git user or a beginner, these cheat sheets can help you streamline your version control workflows and get more done in less time.

Git Essentials with GitLab

Check our latest blog post about “Power of DevOps

Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential