放弃修改 git checkout .
修改commit信息 git commit --amend
撤销上次本地commit
1、通过git log查看上次提交的哈希值
2、git reset --soft 哈希值
分支
1.创建本地分支
git branch 分支名
2.切换本地分支
git checkout mybranch;
3.创建一个新分支并立即切换到这个新分支:
git checkout -b mybranch
4.将远程分支拉取到本地
方法一:git checkout -b 本地分支名x origin/远程分支名x
方式二:git fetch origin 远程分支名x:本地分支名x
5.删除远程分支(将空分支推到远程)
git push origin :develop
6.将本地分支推送到远程分支上(远程没有的话会创建)
git push origin local_branch_name:remote_branch_name
git push origin coze-5ab8e0f3:coze-5ab8e0f3
git push origin yyd_a55_xiaoyong:yyd_a55_xiaoyong
7.将本地分支和远程分支相关联
git branch --set-upstream-to origin/remote_branch_name local_branch_name
git branch --set-upstream-to origin/testbranch testbranch
8、删除本地分支
命令行 : $ git branch -d <BranchName>
git reset HEAD <file> 来取消缓存区的修改。
仓库
1.更换远程仓库
git remote set-url origin [email protected]:wwl_app/ZHJYdemo.git
2.创建远程分支并将本地提交到该分支
git push --set-upstream origin zhjy
3.推送所有分支到新建的仓库
git push --all origin