I have made a git commit
but I have not pushed. And I am now working on a new bug fix, which should not touch the same files as the first commit.
Is it possible for me to commit this bug fix AND git push
only this commit?
All of the commits leading up to a particular commit are what defines that new commit.
That is, if you have a master → dev → bugfix as shown in the image below:
master → dev → bugfix http://img.skitch.com/20091029-tbffrg53q73mdipiwcr3g2ywuh.png
you can push dev
alone but not bugfix
alone, but the definition of bugfix
includes dev
, so dev
has no meaning without bugfix
However, if you build this bugfix out as a feature branch, you'd have something that looked more like this:
feature branch http://img.skitch.com/20091029-t3w5qk3bhj3ftx1d9xnk32ibkb.png
You could still retroactively do that (create a new branch from origin/master
, cherry-pick the change, and then git reset --hard HEAD^
on your development branch to get the bugfix change off of it).
Once that's complete, you can forward-port your dev branch with a simple git rebase master
and it'll look like this:
new master http://img.skitch.com/20091029-1ts3enwsmsr29imcu7tyk75ett.png
In practice, starting bug fixes from a branch will make this kind of thing a lot easier in general.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With