git操作(总有一个示例适合你)

git 配置

git config --global user.name "xiaowang"
git config --global user.email "xiaowang@emial.com"
ssh-keygen -t rsa -C "xiaowang@emial.com" 
cat ~/.ssh/id_rsa.pub

删除本地某个分支

git branch -d <branch name>
git branch -D <branch name>(强制删除)

删除远端某个分支

git push origin --delete <branch_name>

断开本地仓库和远端仓库的联系

git remote rm origin

建立远端仓库和本地仓库的联系git branch -d <branch name>

git branch -D <branch name>(强制删除)
git remote add origin <your_new_repository_url>

列出远端详细信息

git remote -v

基于远端的某个分支新创建一个分支

git checkout -b wyg_add_idc remotes/origin/openEuler-22.03-LTS-SP1-mt

推送本地新分支到远端

git push origin {local_branch}:{remote_new_name}

拿到某次提交的改动并且修改提交人的信息

git cherry-pick d2c6855e12d
git commit --amend --author="xiaowang <xiaowang@email.com>"

提交的时候指定作者

git commit --author="wangyigen <xiaowang@email.com>"

查看最新一次的修改内容

git show

远端回退到 c7b0f649ecb(某次commitid)版本

git reset --hard c7b0f649ecb

git push origin <branch-name> --force

查看暂存区的更改

git diff --cached

如果你想从暂存区中删除某个特定的文件,可以使用 git reset HEAD <file> 命令:

git reset HEAD <file>

对某次commit打tag

git tag {tagName} 10040e3239db

某次tag push到远端

git push origin {tagName}:refs/tags/{tagName}

删除本地tag

git tag --delete {tagName}

删除远端tag

git push --delete origin {tagName}

撤销某次提交

git revert commitId

添加远端仓库

git remote add {remote_name} {remote_URL}

拿到某次提交

git cherry-pick {commitID}

修改最后一次提交

git add 修改文件
git commit --amend
git push <origin> <your-branch-name> --force

生成patch

git format-patch -1 {commit_ID}


 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值