1. Get code

git clone ssh://username@gerrit_server:29418/kernel_goldfish

git clone ssh://fenggxin@10.126.39.248:29418/kernel_goldfish


2. push code

git push ssh://gerrit_server:29418/kernel_goldfish HEAD:refs/for/branch_name

git push ssh://10.126.39.248:29418/kernel_goldfish HEAD:refs/for/android-goldfish-2.6.29


3.  Change-ID

http://gerrit.googlecode.com/svn/documentation/2.0/user-changeid.html

$ scp -p -P 29418 review.example.com:hooks/commit-msg .git/hooks/
$ scp -p -P 29418 10.126.39.129:hooks/commit-msg .git/hooks/


Change-ID is very useful when push task.

If you push one task already, this task is not reviewed and submitted in gerrit server. Now, you find some error and want to do some change for it. Now, you can do like this,

  • modify your code
  • git commit -a --amend
  • git push ssh://10.126.39.129:29418/kernel_goldfish HEAD:refs/for/android-goldfish-2.6.29git push



Please see this picture, in this one task, there will be 2 Patches for it.  Patch set 1 and Patch set 2. So, you don't have to submit another task for it.


4. revert change

If the changes was reviewed and submitted by someone, in sequence, the project owner revert it. Now, you need to do,

git checkout the previous branch before you reverted changes. create a new branch for it, you can work on new branch.

  • $git checkout branchname -b newbranch
  • $git pull
  • $git log      #you can find the logs that change was reverted.
  • $ git fetch http://10.126.39.129:8080/kernel_goldfish refs/changes/02/2/1 && git format-patch -1 --stdout FETCH_HEAD > chard.patch     #get your change content from gerrite, you can find the up command line from gerrit web page.
  • $ patch -p1 < drivers/chard.patch
  • Now, modify your content, and add/commit/push it again.


5.  Generate patch

$cd  <your local repository>

$git log

commit e2a6df4f87e1da14bafcc3bfd0225bedefb00f63
Author: fengxinfeng <xinfeng.feng@tieto.com>
Date:   Wed Jul 11 16:36:16 2012 +0800

    Add my driver chard module.
    
    Change-Id: I6956feeeda3e71c5d1986e04a5bf08d1f3899cf8
    Signed-off-by: fengxinfeng <xinfeng.feng@tieto.com>

commit 5424d42a37a3edd8f18a3f9e7212821adfe7bfe0
Merge: 6ef62c1 b487065
Author: Xinfeng Feng <xinfeng.feng@tieto.com>
Date:   Wed Jul 11 15:49:08 2012 +0800

    Merge "Revert "Add my character driver module, and modify arch/x86/configs/vbox/defconfig add CONFIG_CHARDRIVER=y  CONFIG_CHARD_TEST=m Si

commit 6ef62c11bd4750a5aa4d7d1b1d3d28aec34b4109
Author: Xinfeng Feng <xinfeng.feng@tieto.com>
Date:   Wed Jul 11 15:48:17 2012 +0800

    Revert "modify arch/x86/configs/vbox_defconfig Signed-off-by: fengxinfeng <xinfeng.feng@tieto.com>"
    
    This reverts commit 0e8988d7d04895001a872cc2cbaf283aa04d90e3


 $git format-patch HEAD^

will generate patch file, difference between  e2a6df4f87e1da14bafcc3bfd0225bedefb00f63 andI6956feeeda3e71c5d1986e04a5bf08d1f3899cf8

$git format-patch HEAD^^


6. Check if your code follow the coding Style

After push your code,

$git format-patch HEAD^

will generate patchfile, 0001-*-*.patch

$./scripts/checkpatch.pl 0001-Add-my-driver-chard-module.patch

will display the style errors, like this,

WARNING: line over 80 characters
#336: FILE: drivers/chard/chardev.c:257:
+        printk(KERN_INFO "mknod %s c %d 0\n", DEVICE_FILE_NAME, MAJOR_NUM);

WARNING: line over 80 characters
#512: FILE: drivers/chard/test.c:71:
+            printf("ioctl_get_nth_byte failed at the %d'th byte:\n", i);

total: 0 errors, 9 warnings, 484 lines checked

0001-Add-my-driver-chard-module.patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see


Q&A

Q 1.
remote: ERROR:  In commit cf9ef53e6326502d10c621cbfff1ad8caabfc67f
remote: ERROR:  committer email address xinfeng.feng@tieto.com
remote: ERROR:  does not match your user account.
remote: ERROR:
remote: ERROR:  The following addresses are currently registered:
remote: ERROR:    Xinfeng.Feng@tieto.com
remote: ERROR:
remote: ERROR:  To register an email address, please visit:
remote: ERROR:  http://10.126.39.129:8080/#/settings/contact
remote: 
remote:

solution:

Change golbal configuration

Edit ~/.gitconfig

[user]
    name = fengxinfeng
    email = Xinfeng.Feng@tieto.com

change the last commit

$git commit --amend --author 'fengxinfeng <Xinfeng.Feng@tieto.com>'


Q2.

[remote rejected] HEAD -> refs/for/android-goldfish-2.6.29 (not Signed-off-by author/committer/uploader)

$git commit --amend --s

Add Signed-off-by line by the committer at the end of the commit log message.






Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐