Git基本配置

Git配置


安裝

yum install git

全局配置

#設置提交用戶名
    git config --global user.name "leoxu"

    #設置提交郵箱
    git config --global user.email "xucongjie1990@gmail.com"
    
    #設置分色顯示
    git config --global color.ui true

    #驗證全局配置
    git config -l

基本命令

#初始化本地倉庫
    git init
    git remote add origin git@xxxx.git 
	git add .
    git commit
    git push -u origin master
#clone 遠程倉庫
    #Clone遠程版本庫
    git clone git@115.28.73.167:wangcee/demo.git

    #添加遠程版本庫origin
    git remote add origin git@host:project.git
git add README.md# 將工做文件修改提交到index (什麼是Index,下頁解釋) git add . # 將全部修改過的工做文件提交到index
git reset --hard <version> # 將本地文件空間恢復爲指定的版本,同時修改全部的index及本地庫 git reset (--soft | --mixed | --hard) <version> <file>
git commit <file> #將修改提交到本地庫
git commit
git commit -a # 將git add(或git rm)和git commit等操做都合併在一塊兒作 git commit -am "some comments"

git revert <version> # 撤銷某次提交,撤銷動做自己也建立了一次提交對象 git revert HEAD # 撤銷最後一次提交
#基本diff
    git diff <file> # 比較當前文件和index文件差別 git diff
    git diff <V1> <V2> # 比較兩次提交之間的差別 git diff --cached # 比較index與本地庫差別
    git diff HEAD #比較工做版本與HEAD(本地庫)的差別
#提交記錄
    git log
    git log <file>  # 查看該文件每次提交記錄
    git log -p <file>  # 查看每次詳細修改內容的diff
    git log -p -2  # 查看最近兩次詳細修改內容的diff
相關文章
相關標籤/搜索