centos7
1.在Linux中安装git
yum install -y git
2.创建本地仓库(创建一个文件夹,使用git初始化)
mkdir sixgod
进入该目录进行初始化
git init
3.在GitHub上创建仓库
4.添加远程ssh秘钥
5.本地版本提交:
随意创建一个文件
git add filename 把文件添加到暂存区 多个文件用“,”隔开 当前目录所有文件git add .(点)
git commit -m “注释” 把暂存区别文件提交到仓库
git remote add origin git@github.com:sixgod1013/git.git 关联GitHub上的仓库
设置用户,邮箱,上传代码是会显示是哪个用户上传的:
git config --global username““win10"”
git config --global useemail“admin@e"win.com"
git push -u origin master 将本地仓库的内容提交到远程仓库,第一次提交远程仓库,因为远程仓库是空的所以要加-u
6.当本地仓库有修改后
git add filename
git commit -m “注释”
git pull origin master 远程仓库最新代码,防止有别人提交代码
git push 提交到远程仓库
常用命令:
版本提交:
Git add filename 把文件添加到暂存区 多个文件用“,”隔开 当前目录所有文件git add .(点)
git commit -m “注释” 把暂存区别文件提交到仓库
Git status 查看暂存区文件状态
git diff 对比版本库文件 --cached 为暂存区文件内容
git reset HEAD 将暂存区的文件撤销
git rm 删除文件 -f 强制删除
git mv 重命名
分支管理:
git branch 查看分支
git branch name 创建分支
git checkout name 切换分支
git merge name 合并分支
git branch -d 删除分支
日志信息即每次的提交信息
git log 比较详细
git log --oneline 显示精简信息
标签(版本)
git tag 查看标签
git log --oneline --decor --graph 详细信息
git tag -a -v1.0.0
远程仓库:
git remote 查看当前的远程仓库 git remote -v
git fetch 从远程仓库下载新分支与数据
git merge 远程仓库提取数据并尝试合并到当前分支
git push alias branch
gitpush origin master 推送到远程仓库
git remote rm 删除远程仓库