Software Engineer : How to use git commands properly
As a software engineer, it is necessary to know how to use git. There are always tools or extensions to resolve merge conflicts or push code to repository before you raise Pull Request.
But still I love to use git commands.
If you follow the steps below, you can easily solve merge conflicts.
Lets say you are on your feature branch and you are trying to pull code from dev branch.
1. git pull — all
If more than one developer are working on the same task, before you raise PR it is recommended to pull all latest changes to your local feature branch.
2. git commit -m “feature added”
Now you have the latest changes of feature branch, you can commit your changes and save on your local feature branch.
3. git pull origin dev
Above command will take latest changes from dev branch to your local feature branch.
4. git status
Lets check if there is any merge conflicts inside your feature branch.
If there is, solve merge conflicts and test your code again. It is highly recommended to write test cases (TDD) for your code so that you can easily test your code anytime in future. This will reduce your time later if the later again more changes are required to your code after code review.
5. git commit -m “dev and feature branch merged”
Now save your changes to local feature branch.
6. git push .
Push your local feature branch code to repository.
Thanks for reading. Hope you like it. Follow me on linkedin https://www.linkedin.com/in/shrirang-pinjarkar-3a1b73aa