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

admin4年前复制粘贴2301
#创建一个服务器仓库
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...

linux设置swap分区(转)

1、linux设置swap查看swap位置cat /proc/swaps得到你的swap文件的位置,但不一定叫swap,或许叫/dev/sdb5。关闭并删除较小的swap文件sudo&nbs...

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

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

ubuntu的一些基本设置

一、设置开机启动(/etc/rc.local)将/lib/systemd/system/rc-local.service 链接到 /etc/systemd/system/# ln ...

frp配置(转)

Frp服务的搭建搭建frp很简单,关键的步骤只有三步:1、获取frp文件;2、设置frp配置文件,3、启动frp服务。(注意frp搭建的的这三步是分为客户端和服务端的,但是操作基本是一致的。)本教程f...

发表评论    

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