Git 基础

2017-09-26  本文已影响0人  SmallTank_2017

git 提交

 $ git config --global user.name '名字'
 $ git config --global user.email '邮箱'
cd e:/
mkdir test
cd test
git init    # 创建仓库
git status  #查看仓库状态
git add .   #.代表提交当前目录所有文件,提交到暂存区。git add index.txt提交单个文件
git commit -m “test提交”  # 提交到版本库。"test提交" 为提交的注释

git 删除

git rm delete.txt                # 删除文件
git commit -m "删除delete.TXT"  # 提交删除操作

推送到远程仓库

git push https://github.com/SmallTankpy/lianshou.git master  
git remote add lianshou https://github.com/SmallTankpy/lianshou.git
git add .
git commit -m 'lianshou别名'
git push lianshou master   # lianshou 是远程仓库的别名 master 是本地分支的名字
git remote -v
git remote remove "别名"   # git remote remove origin

团队合作

# 克隆github仓库该地址的项目到指定位置
cd e:
git clone git@github.com:SmallTankpy/lianshou.git  
cd e:/test     # cd 目录
git pull lianshou master

查看日志

git log         # 日志包括作者 日期 版本号等
git log --pretty=oneline   # 查看日志 简化为一行

版本回退、版本控制

git reflog     # 查看所有版本操作日志
git reset --hard “版本号”  # 版本切换

分支

git branch     # 查看分支
git branch "分支名"   # 创建分支  例: git branch tank
git checkout "分支名" # 切换分支  例: git checkout tank
git checkout master  # 切换到master 分支
git merge "分支名"   # 合并分支到master  例: git merge tank
 git branch -d "分支名"    # git branch -d ali

创建 公钥 就不用密码提交了

 ssh-keygen -t rsa -C "381784363@qq.com"
# id_rsa 是私钥 
# id_rsa.pub 是公钥,公钥复制到Github上 SSH方式push
上一篇下一篇

猜你喜欢

热点阅读