git 简单常用命令(持续添加...)

admin3年前复制粘贴1959
#创建一个服务器仓库
git --bare init myRepository.git

#克隆一个仓库到本地
git clone git@服务器ip:/home/git/project/myRepository ./localMyRepository


#添加一个文件到git
git add readme.txt


#提交到本地 -m 为必须 
git commit -m "commit test"

#本地创建创库后与远程仓库连接
git init --initial-branch=master

git add . # 加入本地所有文件
git commit -m "first commit"

# 本地已有仓库推送到远程
git remote add origin http://a.b.com/project.git 
git push -u origin master


#推送本地分支到远程 git push <远程主机名> <本地分支名>  [<远程分支名>]
git push origin master 
#或
git push origin master development


#拉取远程指定分支到本地指定分支
git pull
#或
git pull origin master:development  (master表示远程分支  development表示本地分支)

#使用远程分支强制覆盖本地当前分支内容
git fetch --all
git reset --hard origin/master (master表示远程分支,按实际情况修改)


#查看分支
git branch
#或
git branch -a 


#创建本地分支
git branch myBranch1


#切换到新分支
git checkout myBranch1

#一步到位 创建并切换
git checkout -b myBranch1 

#从远程master分支创建到本地的development 并且切换到development分支
git checkout -b development origin/master


#拉取其他分支提交合并到当前分支
git cherry-pick comintN..commitM  #合并提交comintN(不包含)到commitM(包含)
#或
git cherry-pick comintN^..commitM  #合并提交comintN(包含)到commitM(包含)

#回滚到上一个版本
git reset --hard HEAD^

#回滚到指定历史版本
#git reset --hard xxxx  #xxxx为版本id

#强制推送本地版本到远程仓库
#git push -f origin HEAD  #HEAD 可以 使用 master,具体没试,感觉可能是强制覆盖哪个分支


#列出所有tag
git tag

#利用通配符过滤tag
git tag -l * 

#新建一个tag
git tag v1.0 

#创建带注释的tag
git tag -a tagname -m "comment" 

#查看tag的详细信息
git show tagname 

#给指定的commit添加tag
git tag -a v1.0 commitid -m "comment" 

#将指定tag推送到远程
git push origin tagname 

#切换到某个tag,不在任何branch
git checkout tagname 

#删除某个tag
git tag -d tagname 

#删除某个tag
git push origin :refs/tags/v1.0


返回列表

没有更早的文章了...

下一篇:docker常用命令(持续添加...)

相关文章

js图片压缩(转)

var compressImage = {     compressByFile: function(file,&...

nginx配置ssl证书https(转自阿里云)

80自动跳转443模式server {     listen    80;   &nb...

花生壳和pubyun(原3322)在linux下快速解析

一、花生壳通过设置路由器自定义地址(免费版已经无法解析)http://用户名:密码@/ddns.oray.com/ph/update?&hostname=域名/ curl -fsS...

nginx配置详解(转)

nginx配置文件结构...              #全...

mysql导出指定时间段binlog(需要已经开启binlog)

mysqlbinlog --no-defaults --start-datetime="2018-09-06 13:45:00" --sto...

Ubnt路由器设置ssl证书(转)

根据 Ubnt路由器更换HTTPS证书文件 的说明,更换证书,大部分情况下我们再CA机构拿到的证书一般是 xxx.pem xxx.key 两个文件(nginx)版,或者apache版 xxx.key...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。