When working on a project, I typically follow these same steps over and over throughout the day. This is my standard Git workflow to stay in sync with the main branch while making changes:
-
Check out the
master
(ormain
) branch
Start by making sure you’re working with the latest version of the main branch.git checkout master
-
Pull the latest changes
Get the most up-to-date version of themaster
branch from the remote repository.git pull origin master
-
Check out your feature branch
Create a new feature branch from the latest master or main branch.git checkout -b feature-branch-name
-
Stage your changes
After making updates to your code, stage the changes to be committed.git add .
-
Commit your changes
Commit your staged changes with a clear message describing what you've done.git commit -m "Describe your changes here"
-
Push to the remote repository
Send your changes to the remote repository so others can see and work with them.git push origin feature-branch-name
This quick routine helps keep your local and remote branches in sync, ensures you’re working on the latest version, and keeps your commits organized and shareable. You’ll find yourself running through these steps frequently throughout the day!