GIT命令行的一些常规操作

放弃修改 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

相关推荐
MyikJ1 小时前
Java面试:从Spring Boot到分布式系统的技术探讨
java·大数据·spring boot·面试·分布式系统
化作繁星2 小时前
git忽略校验,强制提交
git
淡水猫.4 小时前
Vulhub靶场搭建(Ubuntu)
安全·web安全·elasticsearch
爱宇阳4 小时前
Git 教程 | 如何将指定文件夹回滚到上一次或某次提交状态(命令详解)
git·git回滚
猎板PCB 邹亮5 小时前
国内高频混压PCB厂家有哪些?
大数据·人工智能·pcb工艺
杰哥技术分享6 小时前
Git 中移除已追踪的文件
git
Microsoft Word7 小时前
Flink
大数据·flink
理***所7 小时前
湖北理元理律师事务所债务优化方案:让还款与生活平衡的艺术
大数据
暗影~行星8 小时前
VS Code 插件 Git History Diff
git
lee5768 小时前
Git 克隆别人的远程仓库以后,推到自己的远程仓库
git