Git 基本操作

Git 基本操作

Git配置
git config –global user.name “your name”
git config –global user.email “your email”

签出仓库
git clone giturl [new dir name]

查看远程仓库
git remote -v

查看远程仓库信息
git remote show [remote name]

添加远程仓库
git remote add [remote name] [giturl]

远程仓库重命名
git remote rename [remote name] [new remote name]

删除远程仓库
git remtoe rm [remote name]

修改远程仓库
git remote set-url --push [remote name] [giturl]

拉取远程仓库
git pull [remote name] [branch name]

推送远程仓库
git push [remote name] [branch name]

将本地分支推送到远程指定分支
git push [remote name] [local branch:remote branch]

查看本地分支(-r 查看远程分支,-a 查看所有分支)
git branch [-r|-a]

创建本地分支
git branch [new branch name]

切换分支
git checkout [branch name]

重命名分支
git branch -m [branch name] [new branch name]

创建并切换到分支
git checkout -b [branch name] [base branch]

直接从远程分支创建
git checkout -b [branch name] [remote name/brnach name]

删除分支(-D 强制删除)
git branch -d[-D] [branch name]

合并分支
git merge [branch name]

删除远程分支
git push [remote name] :heads/[branch name]
git push [remote name] :[branch name]

取消本次修改的内容 ,返回上一次提交状态
git reset –hard HEAD

创建空的分支(执行命令前先提交当前分支)
git symbolic-ref HEAD refs/heads/[branch name]
rm .git/index
git clean -fdx

查看版本
git tag

创建版本
git tag [tag name]

git tag -a [tag name] -m "info"

删除版本
git tag -d [tag name]

创建远程版本
git push [remote name] [tag name]

删除远程版本
git push [remote name] :refs/tags/[tag name]

合并远程仓库的Tag到本地
git pull [remote name] --tags

上传本地Tag到远程仓库
git push [remote name] --tags

查看git的日志
git log

垃圾回收
git gc
文件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值