一. git pull不覆盖修改的代码:
先把修改好的代码存放在缓存里,等代码拉下来以后再恢复缓存里的修改的代码
步骤:
1.git stash save "这里是注释"
2.git pull
3.git stash pop
4.git stash list
5.git stash show
二.若想取消本地的修改:to discard changes in working directory
“git checkout -- <file>
"
注意:--
与file之间有一个空格
git push origin zhangsan:"user/zhangsan/ticket1/
具体请参考https://www.cnblogs.com/zndxall/archive/2018/09/04/9586088.html
三.取消commit而不影响代码:
git reset --soft HEAD^
四.若想add removed的文件到缓存区,则
git add --all <path>
'git add --all <pathspec>' will let you also record the removals.
五.查看指定用户的commit提交
git log --author="ry,d"
六.创建新的分支,并提交代码
1.git checkout develop
2. git pull origin develop
3. git checkout -b user/zhangsan
4. git add
5. git commit -m "this is comment"
6. git push origin user/zhangsan:"this is cloud branch name"
七. 将代码revert到指定commit
1). 将代码revert到42b19aacfb395b8237e38e08ab6cb61b01cd5e0d这个commit,包含当前这个commit
git reset --hard 42b19aacfb395b8237e38e08ab6cb61b01cd5e0d
commit id可以从git页面上拿到
2). 将代码还原到最新的commit(每次拉到最新的分支之后,最好还原到最新commit)
git reset HEAD
八. 删除远程分支
1). 查看当前有哪些分支,其中remote开头的就是远程分支
git branch -a
2). 删除指定的远程分支
git push origin --delete branch_name
或
git push origin -d branch_name
九.配置git用户
git config --local user.email name@qq.com
git config --local user.name name
十:如果不要当前的改动,请重置到库的最新版本:(通过git status的方式可以查看当前有无commit,如果有commit,容易造成commit失败(比如有特定的commit规则))
git status
的时候提示Your branch is ahead of 'origin/develop' by 13 commits.
,如果想丢弃所有的commit,则
1)若想保留本地最新的更改,则:
git push -u origin master
2)若不想保留当前的改动,则重置到库的最新版本:
git reset --hard origin/master
git pull
十一:把develop分支的内容提交到release分支, git cherry-pick
git log
git checkout 要合并的分支
git cherry-pick <commit id>
git push
git log
找到你想提交到目标分支的commit id
commit 3b64693a060a8cf07c66a9545ef969d52f9cbe8c
Author: domi.song domi.song@cloudwise.com
Date: Tue Jun 25 22:07:49 2019 +0800
Fixed #TSB-11111 提交内容
十二:拉取远程分支
git pull (需要先把最新分支信息拉下来,再切分支)
git checkout -b release_BL100 origin/release_BL100( release_BL100是本地分支,origin/release_BL100是远程分支名)
git pull origin release_BL100
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)