What’s the best way to use git branches to easily share temporary commits?
When working by myself, I’ll often do a
git commit -m "WIP"
And then switch branches, do something else, and then switch back to the branch and then do a:
git reset --soft HEAD\^
This could work using 2 pairing developers and using a feature branch, except that when one goes to push, one will overwrite the last WIP commit:
git push origin +my-feature-branch
(Note the use of the syntax of putting a + in front of the feature branch to do a force push, rather than using the --force or --force-with-lease, from the docs: “By having the optional leading +, you can tell Git to update the ref even if it is not allowed by default (e.g., it is not a fast-forward.)”
Another option would be for each developer to have a WIP branch and to then merge each other’s changes as work progresses.
Does anybody have any feeling what might work better?
p.s. If you have any feedback on my blog article, please post here or in the blog article contents. Much appreciated!
You are passing so much bandwidth you don’t need to be passing over a network to render their desktop crap.
I personally have a policy of NOT pushing wip or ever making a commit wip. That does not state what you did and it can lead to broken builds. Don’t push up what isn’t working.
Also, rather than forcing a push (which you should not need to do unless your rebased your commits) you should just push and add a -f IF you changed the tree.
When working with multiple team mates…
get checkout master
git fetch origin
git reset --hard origin/master
git checkout -b rubylove/feature-branch
... do work
git add --all -p
... stage your chosen patches
git commit -m'a good commit message of what you just did'
git push origin rubylove/feature-branch
Then when you are ready to merge your pull request:
get checkout master
git fetch origin
git reset --hard origin/master
git checkout my-working-branch
git rebase master
git push origin
If you would like to pair on this kind of thing today, hit me up Justin. Tweet at me in case I miss it here. @thatrubylove