Git 实用命令

git clone -b feature-branch --single-branch --depth=5 git@git.ssh_address

git commit code:

git status

git add ./

git commit -m 'commit information'

git branch

git push origin feature-branch:myself-branch //在远端服务器创建myself-branch分支,并将 // feature-branch分支code提交上去

撤回提交:

git reset --soft HEAD^ // 不清除暂存区代码

git reset --hard HEAD^ // 清除本地暂存区代码

找回 git reset --hard 的数据:

git reflog // 查看本地提交记录

git reset --hard commit-id // 退回commit-id 处

update code and use same commit:

git commit --amend

git push origin -f

设置git log:

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

设置后 使用 git lg 查看log 更舒适

git push 到远端 发现有冲突:

git pull --rebase origin feature-branch --depth=10; //fetch远端代码

解决冲突

git rebase --continue

git push origin feature-branch:myself-branch

git 拉取某一个分支

git fetch origin feature-branch:local-branch --depth=10 //拉取远端feature-branch分支到本地 //并起名为local-branch

git checkout feature-branch // 切换分支

git cherry-pick commit-id //获取某个commit 进行本地merge

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值