gerrit의git 설정 프로세스

5725 단어 gitgerritOpenstack

1. 환경 변수 설정

  • git 글로벌 사용자 이름 설정
  • git config --global user.name "qujunorz"
    git config --global user.email "[email protected]"
    
    #gerrit          
  • 수정.git/config
  • [remote "gerrit"]
            url = ssh://qujunorz@$  url  
            fetch = +refs/heads/*:refs/remotes/gerrit/*
  • 생성.git/hooks의 commit-msg 파일 # 오류를 피하기 위해 "remote: ERROR: missing Change-ID in commit message footer"
  • #!/bin/sh
    # From Gerrit Code Review 2.7
    #
    # Part of Gerrit Code Review (
    #
    # Copyright (C) 2009 The Android Open Source Project
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    # 
     #
     # Unless required by applicable law or agreed to in writing, software
     # distributed under the License is distributed on an "AS IS" BASIS,
     # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     # See the License for the specific language governing permissions and
     # limitations under the License.#unset GREP_OPTIONS
    
    CHANGE_ID_AFTER="Bug|Issue"MSG="$1"
    # Check for, and add if missing, a unique Change-Id
    #
    add_ChangeId() {
        clean_message=`sed -e '
            /^diff --git a\/.*/{
                s///
                q
            }
            /^Signed-off-by:/d
            /^#/d
        ' "$MSG" | git stripspace`    if test -z "$clean_message"
        then
            return
        fi
    
        # Does Change-Id: already exist? if so, exit (no change).
        if grep -i '^Change-Id:' "$MSG" >/dev/null    
        then
            return
        fi
    
        id=`_gen_ChangeId`
        T="$MSG.tmp.$$"
        AWK=awk    if [ -x /usr/xpg4/bin/awk ]; then
            # Solaris AWK is just too broken
            AWK=/usr/xpg4/bin/awk   
             fi
    
        # How this works:
        # - parse the commit message as (textLine+ blankLine*)*
        # - assume textLine+ to be a footer until proven otherwise
        # - exception: the first block is not footer (as it is the title)
        # - read textLine+ into a variable
        # - then count blankLines
        # - once the next textLine appears, print textLine+ blankLine* as these
        #   aren't footer
        # - in END, the last textLine+ block is available for footer parsing
        $AWK '
        BEGIN {
            # while we start with the assumption that textLine+
            # is a footer, the first block is not.
            isFooter = 0
            footerComment = 0
            blankLines = 0
        }
    
        # Skip lines starting with "#" without any spaces before it.
        /^#/ { next }
    
        # Skip the line starting with the diff command and everything after it,
        # up to the end of the file, assuming it is only patch data.
        # If more than one line before the diff was empty, strip all but one.
        /^diff --git a/ {
            blankLines = 0
            while (getline) { }
            next
        }
    
        # Count blank lines outside footer comments
        /^$/ && (footerComment == 0) {
            blankLines++
            next
        }
    
        # Catch footer comment
        /^\[[a-zA-Z0-9-]+:/ && (isFooter == 1) {
            footerComment = 1
        }
    
        /]$/ && (footerComment == 1) {
            footerComment = 2
        }
    
        # We have a non-blank line after blank lines. Handle this.
        (blankLines > 0) {
            print lines
            for (i = 0; i  "$T" && mv "$T" "$MSG" || rm -f "$T"}_gen_ChangeIdInput() {    echo "tree `git write-tree`"
        if parent=`git rev-parse "HEAD^0" 2>/dev/null`    then
            echo "parent $parent"
        fi
        echo "author `git var GIT_AUTHOR_IDENT`"
        echo "committer `git var GIT_COMMITTER_IDENT`"
        echo
        printf '%s' "$clean_message"}_gen_ChangeId() {
        _gen_ChangeIdInput |
        git hash-object -t commit --stdin
    }
    
    
    add_ChangeId
  • 수정 sshconfig
  • KexAlgorithms +diffie-hellman-group1-sha1
  • 서버에 ssh 키를 업로드
  • 2. 코드 업로드 작업

  • 클론 코드를 로컬
  • 로 복제
    git clone $   gerrit   
  • 신규 분기
  • git branch -a
    #            
    git branch -r 
    #      
    git branch [branch_name]
    ##     
  • 에서 브랜치
  • 로 전환
    git checkout  [branch_name]
         git branch  ,  git checkout -b       
    git checkout -b [branch_name]
  • 파일 수정 및 제출
  • touch aecho “revise” >a
    git add a
    #     ,              
    git addgit commit -a
    #           
    git commit --amend 
    #          ,      ,     git commit --amend    。
  • 상태를 확인하고 마스터에게×××요청
  • git status
    #      
    commitgit  log
    #      
    git-review master

    3. 오보

    sign_and_send_pubkey: signing failed: agent refused operation
    Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rightsand the repository exists.
  • ssh-add 명령을 사용하여 개인 키 참조를 추가합니다.https://help.github.com/articles/error-permission-denied-publickey/
  • 좋은 웹페이지 즐겨찾기