新feature流程
Git checkout <new branch>
修改,commit 后
git checkout develop
git pull –rebase
git merge --squash <new branch> //去除多次提交
git status //查看是否有冲突,使用eclipse处理后 git add .
git diff --cached # double check your diff
git commit –F ~/commit
git push
git branch –D <new branch>
修复bug流程
按上面步骤合并到develop分支后,执行:
git checkout master;
git pull--rebase;
git cherry-pickcommitId //develop的commitId
git push
忘记创建分支
未向develop提交
git checkout -b <new-branch>
已向develop提交
git add -A # 继续在develop上操作,add allfiles you haven't committed
git commit
git pull --rebase
git checkout -b <new branch>
git checkout develop
git reset --hard origin/develop //回复本地develop为远端版本
git checkout <new-branch>
从 development向new branch 更新
$ git checkout <feature-branch>
$ git rebase development
撤销修改
git reset --soft HEAD^ 放弃最新的commit
git reset HEAD 使用工作区替换index
git checkout HEAD --file(.) : 版本库替换index和工作区文件
git clean -fd :清除没有加入版本库的文件和目录 untracked;
忽略文件
git update-index --assume-unchanged <file…> ignore一个文件
git update-index --no-assume-unchanged<file…> 重新track文件
git ls-files -v|grep -e"^h.*" 查看哪些文件被忽略
log记录
git log --since="2 days ago"--until="1 hour ago 某一时间段日志
git log --oneline –decorate --all
git log --graph --pretty=oneline --stat 显示变更摘要:每个commit一行,并显示提交关系
git log -p -1
lg = log --graph --pretty=format:'%Cred%h%Creset-%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'--abbrev-commit --date=relative
其他命令
git status -sb : 显示版本和分支
git add -A 和 git add-u
git add –I (提供交互式界面,选择式添加)
gitp checkout -b <newbranchname> 创建并切换到新分支
git checkout <commit>: 整个工作区切换到历史版本
git checkout <commit> --file: 检出某文件的历史版本
git push origin +master:master 强制推送
git push -u origin new_branch 建立远端 new_branch并推送
git branch --track 遠端branch 建立一個 tracking 遠端 branch 的 branch,這樣以後 push/pull都會直接對應到該遠端的branch。
git branch --set-upstream 遠端branch 將一個已存在的 branch 設定成 tracking 遠端的branch。
find ./ -name "*.xml" | xargs grep "jdbc/jndi-otcp-aus"
git commit --amend -m "新message" 修改上次的提交说明