git分支的创建与合并操作

git分支操作

Git分支操作(<name> ---> 分支名)

查看分支:git branch

创建分支:git branch <name>

切换分支:git checkout <name>或者git switch <name>

创建+切换分支:git checkout -b <name>或者git switch -c <name>

合并某分支到当前分支:git merge <name>

删除分支:git branch -d <name>

克隆指定分支: git clone -b <name> origin

(pull/拉取)指定分支: git pull origin <name>

修改本地分支名: git branch -m <旧分支名> <新分支名>

删除远程分支: git push --delete origin <旧分支名>

将新分支名推送到远程仓库: git push origin <name>

Git撤销上次commit提交

Git撤销上次commit提交(还在本地)

1.git reset --soft head~1 (撤销上一次commit, 不会撤销git add)

2.git reset head~ (撤销上一次commit, 同时撤销git add)

Git版本回退 (git log 可以查看 commit_id)

Git版本回退()

1.git reset --hard head^ (回退到上个版本)

2.git reset --hard head~2 (回退到第2个版本)

3.git reset --hard commit_id (回退到指定版本)

谨慎操作 回退之后就看不到回退版本之前的 commit_id 了

Git remote(修改远程仓库)

1.查看远程仓库: git remote -v

2.删除远程仓库: git remote rm origin/仓库名

3.添加远程仓库: git remote add origin/仓库名 URL

Git合并历史 – (refusing to merge unrelated histories)

git pull origin master --allow-unrelated-histories

Git tags

1. git tag -a v版本号 -m "说明"
2. git push origin v版本号
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值