常规 Git check in/out 代码流程,仅供参考和个人MEMO
默认check in的是 master branch
1. clone repo from remote to local
Say remote repo is test:
1) git clone url_to_remote_repo/test.git test
2. create repo from client side
git init then git add . .. or use git clone xxx/new_repo.git new_repo
3. create local workspace branch and switch to it.
git branch mylocal ; git checkout mylocal
4. Git add
add/modify/delete in local workspace branch,针对不同的修改可以采用不同的git add 参数
git add -A : 可以把所有的变化都track
git add -u : only for deleted and updated, can't include new added
git add .: only new added and updated, without delete.
如果需要放弃对某个文件的修改: git reset HEAD filename
5. git commit
-m "your messgae" 或者 -F commit_content_file
生成changeset, 可以使用 git log -1 查看 commit message
5.5 git commit 追究修改
git commit --amend
Note: 此处该命令会导致 changeset 重新生成一次。
还不知道如何保持changeid 不变(在--amend 里面 最好一行天津 Change-Id: old_ID 该方法对我似乎不起作用)
有知道的可以告知一声咯~
6.根据需要在此时生成review request,review 通过后继续
7.git checkout master then 更新本地master branch
git pull ; git reset --hard origin;
8.git checkout mylocal, 检查冲突
git rebase master
9. fix conflicts , 然后git rebase --continue
此步骤循环直至没有冲突
10. git checkout master; git merge mylocal
将local workspace的内容merge到本地master 中
11.为了谨慎起见,使用 git diff 对比 origin master 和本地master
首先 git log origin/master..master 查看是否只有一个 commit 输出
然后 git diff origin/master..master 查看 diff内容
12 最终check in
git push origin master. 最好是指出远端对应的branch(此次是master)
check in的时候 可能会遇到conflicts 可能是在pull 之后的时间发生了新的check in,此时需要reset master,从7 步骤开始重走一遍。