下载项目
git clone https://github.xx.com/xx
0. Make sure my local master is sync'ed with upstream
- git checkout master
- git fetch upstream
- git rebase upstream/master
- git push -f
1. Create a new branch for a feature or bugfix, commit to local git
- (continue)
- git checkout -b fix-title
- (work on changes)
- git add .
- git commit (Add 'Closes: #issue-number' when necessary)
2. Push the change to my forked repo (i.e. origin)
- git push -u origin fix-title
3. Raise PR against the upstream
- Open browser, goto github.ibm.com my repo
- Create Pull Request
* from my local fix-title branch
* to upstream/master
4 .Wait for PR to be reviewed, discuss, merge
***** If further changes needed ******
1) ensure upstream changes are sync'ed, again
- git checkout master
- git fetch upstream
- git rebase upstream/master
- git push
2) rebase my branch to upstream/master
- git checkout fix-title
- git rebase upstream/master (maybe there are conflicts to be solved)
* (edit the conflict file)
* git add <conflict-file>
* git rebase --continue
- (work on further changes)
- git add .
- git commit --amend (Don't change the commit message unless necessary)
3) Push change to my fork
- git push -f
git rm xx 标记删除文件
vim ~/.gitconfig #缩写命令配置文件位置
git diff xxxxx #比较修改
git checkout -b xxxxx #新建分支
git log -p #查看当前分支历史修改
git log -p xxxxx #查看xxxxx分支历史修改
git branch -D xxxxx #删除本地branch
git push -u origin --delete xxxxx #删除远端branch
git pull -p #如果远端分支删除,清理本地分支
git branch #本地分支
git branch -a #所有branch
git remote -v #当前branch的所有上游
#rename branch修改分支名
git co master #切换到其他分支,比如master
git br -m parse-tran activity-type #parse-tran改为activity-type
如果需要完善git刚上次的提交:
git add xxxxx #标记修改的文件
git commit --amend #改善提交(可修改上commit信息)
git push -u origin xxxxx -f #强制推动 xxxxx分支 本地新的提交
如果git add的文件多了,
git reset HEAD xx #拉回文件
冲突解决办法:
1.rebase
git fetch upstream
git rebase upstream/xxxxx #rebase xxxxx分支到当前分支
2.不要当前分支,重新checkout一个新分支
git checkout -b chart-view upstream/chart-view
3.reset强制干掉自己的代码
git log
git reset --hard bbd4df56e89f5eddd0e4ed0990834e8f8366a208
(git reset --soft会保留代码)
git push -f
或
git push -u origin 之后有冲突,拉回本地文件命令:
git reset HEAD 文件名
git checkout 文件名
git push -f
提交了5个文件,已经push了,撤回其中一个文件
git rm -f core/migrations/0021_auto_20181106_1605.py
git add core/migrations/0021_auto_20181106_1605.py
git commit --amend
git push -u origin xxxxx分支 -f
git log
git rebase -i 94ab45xxx 改变当前分支的rebase上游
git log -p
git commit --amend
git push -f
用upstream/release-0.2当上端分支,取数据
git branch -a #查看所有分支
git checkout -b release-02 upstream/release-0.2 #copy数据
git push -u origin release-02 #本地上游分支
git br
git checkout -b release-02-dev
git push -u origin release-02-dev