git常用命令

        git常用命令

新建分支
# 拉取远程仓库
$ git pull

# 新建分支
git checkout -b dev_newstyle(分支名)

# 推送分支到远程
git push origin dev_newstyle(分支名)
git push

# 删除远程分支
git push origin --delete dev_newstyle(分支名)

# 删除本地分支
git branch -D dev_newstyle(分支名)

提交
# 添加全部已改变的文件到暂存区
$ git add .

# 提交到本地
$ git commit -m '描述'

# 提交到远程
$ git push

暂存
# 查看分支
$ git branch

# 将当前修改内容(但并未提交状态,未加入暂存区的内容)储存起来
$ git stash save '暂存训练'
# 注:save 后 表示储存描述 ,可以不加

# 查看储存的未提交内容(j接上一步)
$ git stash list
stash@{0}: WIP on 分支名: 82f99ff 暂存训练

# 恢复储存的未提交内容,需要用到上一步的索引 stash@{0}
$ git stash apply stash@{0}

# 清除某一项
git stash drop stash@{<number>}

# 清除所有
git stash clear
回退提交内容
# 回退已经commit的内容
# 1、查看提交记录,并记录你要回复的记录后面的commit索引
$ git log
commit 82f99ff0e0d25b4a2ebc2864124e4e156ad84fb8 (HEAD -> zhibiao_qhq)
# 2、回退
$ git reset --hard 82f99ff0e0d25b4a2ebc2864124e4e156ad84fb8 

# 将回退后的代码,同步推送到远程 Git 仓库
$ git push origin 分支名称
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值