Over the years, I’ve found myself relying on a core set of Git commands on a daily basis. These commands help me manage code changes, synchronize with team members, and maintain a clean project history.
Here’s a rundown of the top 10 Git commands that are indispensable in my daily workflow.
1. git clone
Before you can work on a project, you need to get it onto your local machine. The git clone command does just that by copying an existing Git repository from a remote location to your local machine.
2. git status
Once you’ve started making changes, it’s crucial to keep track of your work. The git status command provides a summary of which files have been modified, which are staged for commit, and which are not being tracked by Git.
3. git add
When you’re ready to save changes in Git, you first need to stage them using the git add command. This command updates the index with the current content found in the working tree, to prepare the content staged for the next commit.
4. git commit
Committing is like taking a snapshot of your project’s currently staged changes. The git commit command captures your changes in a new commit along with a log message from the user describing those changes.
5. git push
After committing your changes locally, you’ll want to share them with your team or update the remote repository. The git push command uploads your commits to the remote repository.
6. git pull
To synchronize your local repository with the remote, use the git pull command. It fetches and merges changes on the remote server to your working directory.
7. git branch
Working on a new feature or fix? The git branch command helps you manage your branches and ensures that you’re working in the right context.
8. git checkout
Switching between branches is a common task. The git checkout command lets you navigate to different branches in your repository.
9. git merge
Once your feature or fix is ready, you’ll need to merge your branch back into the main branch. The git merge command combines the history of the specified branch into your current branch.
10. git log
To view the commit history of your project, the git log command is invaluable. It shows the chronological commit history for the current branch.
Incorporating these commands into your daily workflow can significantly improve your productivity and collaboration efforts on any Git-based project.
Besides all the commands above, I will check [dev resources](https://cheatsheet.md) in case I forget something.
Hope this tip helps!