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
拉取远程仓库
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]
上传本地Tag到远程仓库
git push [remote name]
查看git的日志
git log
垃圾回收
git gc
文件