1. 如何reset本身本地的修改?html
選中指定的返回版本,右鍵菜單選擇「reset to this commit」, 而後選擇hard 模式。git
2. 如何解決兩個分支間的conflict?服務器
1. merge develop 到feature,首先merge A 到 B,修改conflict,而後提交。架構
2. merge feature 到develop,首先merge develop到feature,解決conflict問題,而後pull request,merge feature 到 developfetch
經典git教程:this
http://git-scm.com/book/zh/v1url
http://www.ruanyifeng.com/blog/2012/07/git.htmlspa
git 架構code
git會有兩個倉庫,一個是remote repository,再遠程服務器上,一個是local repositoryorm
git的三個區域:
remote repo --------------- local repo ----------------- local work area
git fetch 從remote repo 到 local repo
git checkout : 從local repo 到 local work area,切換工做區域和local repo的分支
git pull : 從remote repo 拉到 local repo 和 local work area.
git 一些經常使用命令,及區別
git branch 建立分支
git checkout 建立或切換分支
git fetch 將服務器的文件同步到本機器的服務器分支
git pull = git fetch + git merge to local
git reset --hard HEAD 將work area版本指向本地的最新版本。
典型的更新流程:
git checkout master git fetch git diff origin/master git pull --rebase origin master
git add 添加文件
提交本地修改,並merge到本地的master分支
git commit
git checkout master
git merge branchname
提交到遠程master分支
git push origin master:master
===============================
// 添加Git submodule倉庫
git submodule add <remote_url> <local_path>
// 對於clone一個有submodule的倉庫,是不會把submodule也clone下來
// 須要額外的步驟:
// 1. 註冊submodule到.git/config裏
git submodule init
// 2. clone submodule
git submodule update --recursive
// 上面兩步等價於下面
git submodule update --init --recursive
// 若是修改了.gitmodule的remote url,使用下面的命令更新submodule的remote url
git submodule sync
如何更新module 子模組?
1. 先到子模組目錄,git checkout master,git pull 更新同步 子模組
2. 再到父repo,查看狀態git status,子模組更新狀態會留在 super-repo
3. 提交子模組狀態 git commit...