Git使用經驗總結

來源:互聯網
上載者:User

標籤:git 經驗

1. Git如何獲得兩個版本間所有變更的檔案清單


用“git log”或者“git log|grep <name>”查到關注的版本的雜湊值,然後


git diff dd1b3f4d24e9bc8813e0ddb68396684aa2cd684d 83ca581804524f0d271c82779b102bb20cca32ce --stat

或者 

git diff dd1b3 83ca5 --stat

前4~6位就可區分


2. 典型的git checkout/checkin操作

git clone ssh://192.168.27.12:29418/8939/amss_oem/modem_proc.git -b develop-bp-master-37

git checkout -b tangjian_bug42272

git add <file>

git commit -m "bug 42272, provide different header file according to different project" files

git push ssh://[email protected]:29418/8939/amss_oem/modem_proc.git HEAD:refs/for/develop-bp-master-37


一般除非檔案很多,不主張用

git add .

否則很多中間編譯產生的檔案也add到cache中了。


對於git push和git pull,可以寫個指令碼。

#!/usr/bin/env python# -*- coding: utf-8 -*-import sysimport osimport argparseclass InputError(Exception):    def __init__(self, value):        self.value = "Build Variant Input Error: " + value    def __str__(self):        return repr(self.value)prompt = "please give input like $0 -a pull -m bp -s modem_proc -n 40 "parser = argparse.ArgumentParser()parser.add_argument("-m", "--module")parser.add_argument("-s", "--submodule")parser.add_argument("-n", "--no")parser.add_argument("-b", "--branch")parser.add_argument("-a", "--action")args = parser.parse_args()if args.module == None or args.submodule == None or args.no == None or args.action == None:    raise InputError(prompt)br = "develop-" + args.module + "-master-" + args.nofolder="8939"if args.module == "ap":    folder += "/platform"else:    folder += "/amss_oem"cmd = "git %s ssh://192.168.27.12:29418/%s/%s.git HEAD:refs/for/%s"%(args.action, folder, args.submodule, br)print cmdret = os.system(cmd)

3. git clean -df, 清除不在庫中的檔案

Git使用經驗總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.