Common Workflows In Git For Developers
In this article we will look at some common Git workflows.
- Connect local repo to Github repository
- Check if any new changes in remote
- Force pull to overwrite local files
- Exclude some files/directories from staging
- Working on tags
Connect local repo to Github repository
At a later point, you might want to connect the local repo with the Github repository. To do that, initiate the git project and sync it by following the below commands.
Check if any new changes in remote
Sometimes we may want to check if any new changes are available in remote before pulling the changes. To check that, execute the below sequence of Git commands.
Force pull to overwrite local files
You may be faced the below error when trying to pull changes from the remote.
To fix this issue, we need to first either save local changes by stashing them ‘git stash’ or discard local changes with the below commands
After the local changes are cleaned then, execute ‘git pull’
Exclude some files/directories from staging
If you want to skip some files/directories from staging, then use the below command.
Working on tags
Commit all your changes and look below commands for your specific need.
Read this Git Cheat Sheet for quick overlook of Git commands.