GIT : Basic workflow for bugfixes
A list of all the steps that make for a clean working procedure in a standard situation: assuming a small bugfix ticket.
To show more clearly, what is going on, no shortcut-commands have been used.
For setting up GIT, see: InstallingOnWindowsGettingBwRox (although that's for Windows, procedure on Linux & Mac should be the same)
- Update your local repository.
git checkout develop git pull <remotename> develop
<remotename> is the name for the remote repository that you used, while setting up GIT for BW-Rox.
2a. Create a branch for the issue that you are working on, branchname should very shortly describe what it contains (like trac-nr, example : "fix1234") :
git branch <branchname>
2b. Switch to this branch:
git checkout <branchname>
- Change what you need to change in your editor/IDE.
- Test on your localhost. And test again.
Also check related features to see if you maybe broke anything there.
- Stage all modified files that need to go to the server:
git add <filename>
Tip: You can get a list of modified files with "git status".
Alternative: Stage all modified files with one command "git add ."
- Commit to your local repository, always include tracnr in message, keep it short but clear (others will see this)
git commit -m "[XXXX] commit message"
- Resynch local develop with the develop in the main/remote repository (in case other people have made changes)
git checkout develop git fetch <remotename> develop git pull <remotename> develop
- Rebase and optionally squash your subcommits into 1 new
git checkout <branchname>. git rebase -i develop
This will bring up a list of commits that you can include in the rebase.
For each ticket you can either:
- pick (default), meaning that it will be committed independently, you could edit the message if you want
- squash, meaning that it will be merged with the commit above it
- fixup, as squash, but you’ll lose the commit message of the lower commit.
edit the the commits as you wish. Enter the insert mode with:<ESC> i
and save&close with
Step 9 is optional
9a. Publish the changes to your own remote repository. After this you can ask others to check your changes.
For bigger projects others could even contribute to your branch this way.git push origin <branchname on origin>
9b. Get the data back from your own remote repository into local branch
git checkout <branchname locally> git pull origin <branchname on origin>
After following step 9, you’re not allowed to Rebase this code anymore!
- Merge the changes you made locally into develop
git checkout develop git merge <branchname>
- Push to the develop-branch of the main repository
git fetch <remotename> develop git push <remotename> develop