grrr... Okay, so I'm trying to add a 'Signed-off-by' line to a commit I already pushed to my origin on github. (Pull request #24). Normally, I do this:
$ git remote update upstream
## rebase if necessary (new-api hasn't changed here, so not necessary)
$ git rebase -i commitish^
## make it reword the commit, add 'Signed-off-by'
$ git format-patch ...
$ git send-mail ...
However, in this situation (using github) I think it should go like this:
$ git rebase -i commitish^
## make it reword the commit
$ git push origin
## where 'origin' is my github remote.
Unfortunately, I get the following in response to my push:
To g...@github.com:jac299792458/libfreenect.git
! [rejected] local-new-api -> local-new-api (non-fast-forward)
error: failed to push some refs to 'g...@github.com:jac299792458/libfreenect.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
Anyone done a commit edit and push to github before?
thx,
Jason.
> On 11/19/2010 02:27 AM, Kyle Machulis wrote:
> > If you don't understand it, ask
> > in this thread or the IRC channel.
> >
>
> grrr... Okay, so I'm trying to add a 'Signed-off-by' line to a commit I
> already pushed to my origin on github. (Pull request #24).
[...]
> However, in this situation (using github) I think it should go like this:
>
> $ git rebase -i commitish^
>
> ## make it reword the commit
>
> $ git push origin
>
> ## where 'origin' is my github remote.
>
> Unfortunately, I get the following in response to my push:
>
> To g...@github.com:jac299792458/libfreenect.git
> ! [rejected] local-new-api -> local-new-api (non-fast-forward)
> error: failed to push some refs to 'g...@github.com:jac299792458/libfreenect.git'
> To prevent you from losing history, non-fast-forward updates were rejected
> Merge the remote changes before pushing again. See the 'Note about
> fast-forwards' section of 'git push --help' for details.
>
> Anyone done a commit edit and push to github before?
>
AFAIK rebase and push does not play well together because of how rebase
works:
http://stackoverflow.com/questions/559917/git-rebase-and-git-push-non-fast-forward-why-use
http://stackoverflow.com/questions/2219424/how-to-push-pull-git-rebase
I think the rule of thumb is: rebase only your own _local_ stuff.
If you want to rewrite the history and push an updated version of it to
the remote repository I guess you can do that with "git-filter-branch"
somehow. I don't know if that plays well with the pull request tho.
Regards,
Antonio
--
Antonio Ospite
http://ao2.it
PGP public key ID: 0x4553B001
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
Use the git push -f.
But again, listen to Antonio. It's generally bad practice to
force-push to a public repo. That said, we do have to sign off
commits before they get integrated.
--
Kelvie Wong
Yep, a cup of coffee later I saw more clearly what I needed to do.
> But again, listen to Antonio. It's generally bad practice to
> force-push to a public repo.
I agree completely. The advantage of the lkml method over the github method is the ability to take critiques and edit commits _before_ merging into a public repo.
It looks like all the branches were merged into master, so I'll have to rebase against upstream/master anyway...
> That said, we do have to sign off
> commits before they get integrated.
>
Yep, usually format-patch/send-mail handled that for me. I'm still new to the collaborative aspects of git.
Thanks for the input.
Jason.
One of the reasons we chose to require sign-off in the commit comments is that this makes it very clear which code is from which contributor and this record travels with the repository. This way we don't depend upon a website or a mailing list which may have it's own issues. We're taking advantage of the distributed nature of DVCS/Git and everyone has a record.
Jason,
I had the same problem. I worked around it by creating a new branch, call it 'signing', branched before my unsigned changes. Then I merged with --squash from the 'unsigned' branch into the 'signing' branch. When you commit there you can sign it at that point. And then you can merge signed back into the 'unsigned' branch. This worked for my repo.
I'm not a git expert but this seemed to work for me. If someone considers this improper please speak up. But as far as I can tell it's a relatively painless way to do this after having pushed to a publicly available repo.
Tully
While this is a solution, you lose the granularity of your commits. I
assume each commit was a logical separation of work and history, and
by squashing them, you make it very difficult to separate them again.
You can no longer revert specific commits, nor bisect in-between them,
or even know which commit message refers to which change easily.
It does work around the sign-off problem though.
--
Kelvie Wong
This solution seems to be the best for this scenario:
git checkout -b [new-branch] [branch-to-change-commit-on]
git commit --amend
git push [remote] [new-branch]
git push --delete [remote] [branch-to-change-commit-on]
Then redo the pull request from the new branch. Thanks to Kyle for suggesting this to me...
hth,
Jason.
While this is a solution, you lose the granularity of your commits. I
assume each commit was a logical separation of work and history, and
by squashing them, you make it very difficult to separate them again.
You can no longer revert specific commits, nor bisect in-between them,
or even know which commit message refers to which change easily.
It does work around the sign-off problem though.
--
Kelvie Wong
This solution seems to be the best for this scenario:
git checkout -b [new-branch] [branch-to-change-commit-on]
git commit --amend
git push [remote] [new-branch]
git push --delete [remote] [branch-to-change-commit-on]
Then redo the pull request from the new branch. Thanks to Kyle for suggesting this to me...
hth,
Jason.
I believe Kyle is working on a write up right now...
thx,
Jason.
To facilitate things, one could do the following:
$ cd /path/to/libfreenect.git
$ git config --add format.signoff true
NOTE: understand what you are doing when you enable this.
1.) _All_ future commits to this repo are under the license of the
code already in the repo.
2.) You have the authority to place your work under that license.
3.) You're read and fully understand section 12 of
Documentation/SubmittingPatches in the linux kernel [1].
hth,
Jason.
Of course, I hadn't suggested otherwise :)
I just think that using squash as a replacement for merge is a bad thing.
The people over on the Mercurial side disagree with our sentiments,
though; they employ the "take all commits, warts and all" philosphy,
or so I've heard.
--
Kelvie Wong
I added a section on the wiki that helps with this:
http://openkinect.org/wiki/Contributing_Code#Forgetting_to_sign_off_after_committing
If anyone wants to take a look and/or add to it.
--
Kelvie Wong