Git global setup
git config --global user.name "xiaohuge"
git config --global user.email "[email protected]"
Create new repository
git clone [email protected]:kongrun/LeetCode.git
cd test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder or Git repository
cd existing_folder
git init
git remote add origin [email protected]:kongrun/LeetCode.git
git add .
git commit -m "leetcode"
git push -u origin master
如果希望保留生産伺服器上所做的改動,僅僅并入新配置項, 處理方法如下:
git stash
git pull
git stash pop
然後可以使用Git diff -w +檔案名 來确認代碼自動合并的情況.
反過來,如果希望用代碼庫中的檔案完全覆寫本地工作版本. 方法如下:
git reset –hard
git pull
1 git基本配置
gitconfig–globaluser.namezhangan git config –global user.email [email protected]
應用配置級别
–local(本地倉庫) > –global(目前使用者) > –system(整個系統)
2 檢視配置
$ git config –list –global
git config –get-all user.name #local repo git config file)
git config –global –get-all user.name #user config file)
git config –system –get-all user.name #system git config file)
git commit已送出的Author資訊可以通過git log檢視
$git log