git commands to manage work
It’s very important when you are workin on big feature (which takes more than a day to complete) to take out latest code from target branch ( the one where I wish to merge my code eventually ) and merge in current working branch at-least once a day. For past few years I have been used to IntelliJ/PyCharm IDE which has spoiled me with it’s UI options so much that at times I find it hard to re-collect underlying git command.
This note is to remind myself about those commands just in-case I have to work in environment where these IDEs are not available.
My usually workflow :
- I would first take out latest of my target branch in local ->
sh git checkout target-branch
- Then I would create a work branch out of it. ->
sh git checkout -b feature/branch-1
- I would do frequent commits in this to save my work. ->
git add file_name/s && git commit -m "commit_message"
- Generally for every commit or maybe for once or twice a day would push it to upstream origin with ->
git push origin feature/branch-1
- To make sure I have latest of target branch ->
git checkout target-branch
- Then pull latest of it ->
git pull origin target-branch
- Switch back to working branch ->
git checkout feature/branch-1
- And merge latest changes of target in my work ->
git merge target-branch