Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Friday, January 13, 2012

How to send patches via git-send-email

In the past I either directly commited to git or send - if needed - my patches to e.g. mailing list by exporting the patches from my local git repo via 'git format-patch -s origin' and then importing them into my mailer. Yesterday I finally found some time to get git-send-email running to do this for me directly on command line.

First you have to choose if you always use the same email account to send your patches. In this case you need to configure 'git-send-email' this way:
git config --global sendemail.from "YOUR NAME <user@example.org>"
git config --global sendemail.smtpserver imap.example.org
git config --global sendemail.smtpuser USER
# depending on your config you may also set:
git config --global sendemail.smtpencryption tls
If you don't want to enter password for your SMTP server all the time:
git config --global sendemail.smtppass = PASS
If you use different settings/email accounts for different project, you can setup different identities for them. Here one example for btrfs project:
git config --global sendemail.btrfs.to "linux-btrfs@vger.kernel.org"
git config --global sendemail.btrfs.from "YOUR NAME <user@example.org>"
git config --global sendemail.btrfs.smtpserver imap.example.org
git config --global sendemail.btrfs.smtpuser USER
git config --global sendemail.btrfs.smtppass = PASS
git config --global sendemail.btrfs.smtpencryption tls
There are some other options you may should use as e.g.:
git config --global sendemail.chainreplyto false
to set the threading format to shallow/flat instead of the deep threading, which is much more readable on a mailing list if you send multiple patches at once.

Now you can send you patches with (you may have to replace origin with the revision you need):
git send-email --annotate origin
If you use an identity e.g.:
git send-email --identity=btrfs --annotate origin
If you didn't commit your changes into your local git branch with the -s option (to get the 'Signed-off-by:' line) you need to add the --signoff option, as I realized after sending my latest patches to the btrfs mailing list. If you send a patch series you may also want to use a cover email to explain something or to write more info. In this case you can use --cover-letter to get git to create and let you edit such an email before sending. 

Here the full example command I would use to send my patches:
git send-email --identity=btrfs --annotate --cover-letter --signoff origin
For more info check e.g. the Git Community Book or use your favorite internet search engine.

Monday, October 31, 2011

Git trouble shooting: none-bare repository

I had some trouble with my git repositories at freedesktop.org in the past, as you may remember [1,2]. Last week I run in some trouble again. As it looks, they updated the git server to a new version, since the update I got the following error message on push:
[...]
error: refusing to update checked out branch: refs/heads/master
error: By default, updating the current branch in a non-bare repository
error: is denied, because it will make the index and work tree inconsistent
error: with what you pushed, and will require 'git reset --hard' to match
error: the work tree to HEAD.
error:
error: You can set 'receive.denyCurrentBranch' configuration variable to
error: 'ignore' or 'warn' in the remote repository to allow pushing into
error: its current branch; however, this is not recommended unless you
error: arranged to update its work tree to match what you pushed in some
error: other way.
error:
error: To squelch this message and still keep the default behaviour, set
error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://dkukawka@people.freedesktop.org/~dkukawka/hal.git
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://dkukawka@people.freedesktop.org/~dkukawka/hal.git'
Unfortunately the instructions from the error didn't help me to make push work again. I tried 'git reset --hard'and also to clone the repo again from the server, apply the new patches etc. but it didn't work. Here is what I had to do to get it work again:

  • login to the remote server with the git repository
  • go to the repository directory
  • call  'git config --bool core.bare true'

  • I don't know how it happened in the first place to be non-bare, but this should set the remote repository again to a bare repo and you are able to push again.

    Saturday, February 27, 2010

    How to move local git repo with branches to a server

    As my HAL/hal-info git repos were lost last year at people.freedesktop.org, I restored them from my last existing local checkouts. I simply copied the local checkout/repo to the server and created a new git repository as proposed in the git user manual:

    git clone --bare ~/hal hal.git

    touch hal.git/git-daemon-export-ok

    But as I, some months later, tried to switch to my hal-0_5_12-SUSE_CODE11 branch, there was no such branch. To be exact: there was neither this branch nor any of the upstream branches. I couldn't find any information on the web how to solve this problem. Everything I tried didn't work. When I cloned the new repo from the upstream repo, all branches where available.

    At the end I found my own solution once I compared the .git/refs/ directories of the cloned repo from the upstream and the local repo. Looks as if the clone command don't copy the branches under .git/refs/remotes/origin/ to .git/refs/heads/ if you use a local repo/checkout as source. Here is what I did to get my branches available again:

    cd hal

    find refs/remotes/origin/ -type f | grep -v -E 'HEAD|master' | xargs cp --target=../hal.git/refs/heads/

    I don't know if there is an other, more standard, way to do this. I couldn't find anything else and at least it solved the problem for me.

    Tech Tags: