git stash暂存的操作
1. 暂存操作
git status #查看当前状态
git add . #如果有修改,添加修改文件
git stash save '本次暂存的标识名字' #暂存操作
2. 查看当前暂存的记录
git stash list #查看记录
3. 恢复暂存的工作
git stash pop stash@{index} #恢复指定的暂存工作, 暂存记录保存在list内,需要通过list索引index取出恢复
git stash apply stash@{index} #恢复指定的暂存工作, 暂存记录保存在list内,需要通过list索引index取出恢复
4. 删除暂存
git stash drop stash@{index} #删除某个暂存, 暂存记录保存在list内,需要通过list索引index取出恢复
git stash clear #删除全部暂存
分支操作
切换远程分支:git remote set-url origin git@gitlab06.tclking.com:tvos/tbrowser/tbrowser3.0.git
查看本地分支:$ git branch
查看远程分支:$ git branch -r
创建本地分支:$ git branch [name] ----注意新分支创建后不会自动切换为当前分支
切换分支:$ git checkout [name]
创建新分支并立即切换到新分支:$ git checkout -b [name]
删除分支:$ git branch -d [name] ---- -d选项只能删除已经参与了合并的分支,对于未有合并的分支是无法删除的。如果想强制删除一个分支,可以使用-D选项
#使用该方式会在本地新建分支x,并自动切换到该本地分支x。采用此种方法建立的本地分支会和远程分支建立映射关系。
拉取远程分支:git checkout -b 本地分支名 origin/远程分支名
#远端即可创建新的分支my_remote_new_branch,提交本地修改
git push代码到远程新分支:git push origin master:my_remote_new_branch
提交Master代码
#step1:同步远程代码
git pull
#step2:提交本地修改
git commit -m '
Description:fix gradlew.bat build error
Cause:Lint found errors in the project
Function:add abortOnError false to continue the build even when errors are found
Reviewed:zhongzw
TestCaseId:
BugId:
'
#step3、提交到远程服务器
git push
提交feature分支
git pull
git branch feature
git checkout feature
git add 文件
git commit -m '
Description:fix gradlew.bat build error
Cause:Lint found errors in the project
Function:add abortOnError false to continue the build even when errors are found
Reviewed:zhongzw
TestCaseId:
BugId:
'
git pull
git push -u origin feature #第一次上传建立连接
git push origin feature #第二次后上传到远程服务器
将master代码同步到feature上
git checkout master
git pull
git checkout feature
git merge master
git push
git remote show origin #查看远程分支状态
git remote prune origin #清理无效的远程分支
git checkout master
git branch -a
git branch -d feature #删除本地分支
git reset --hard HEAD^ #还原上一版本commit
git reset --hard 44bd896bb726be3d3815f1f25d738a9cd402a477