git
Git
- 此文档介绍git命令及相关操作,不涉及git原理
准备工作
用户信息设置
git config --global user.name "###"
git config --global user.email "###"
查询config列表信息
git config --list
获取config命令手册
git help config
初始化仓库
git init ### 克隆仓库
git clone https://##### ### 克隆仓库并在本地重命名
git clone https://##### rename//重建仓库名为rename ### 检查仓库状态
git status
git status -s //美化版,前缀??未跟踪文件A暂存区文件M修改过的文件
跟踪新文件&把已跟踪文件放到暂存区&用于合并时把有冲突的文件标记为已解决状态
git add 文件 ### 比较当前文件和暂存区域快照之间的差异
git diff ### 查看已暂存将要添加到下次提交里的内容
git diff --staged $ git config --global user.name "##" $ git config --global user.email "##" $ cd E:/ 定位到E盘 $ mkdir test 创建版本库 $ git init $ git status 查看仓库状态 $ git add index.html /git add .(提交当前目录所有文件)提交至暂存区 $ git commit -m "注释" 提交至版本库 $ git push -f 同步至远程仓库 修改文件 $ git add index.html(修改后) $ git commit -m "修改注释" 删除文件 $ git rm index.html $ git commit -m "删除注释" 推送至远程仓库 $ git remote add 代号名 https://..... $ git remote 查看代号名 $ git remote -v 查看代号地址 $ git remote remove 代号名 $ git push 代号名 master
$ git push https://… master
clone项目
$ git clone https://…
同步最新代码
$ git pull 代号名 master
查看改动日志
$ git log 查看项目日志
$ git log
如果用命令行的话,应该需要删除 本地控制面板中的账户下面的凭据 并且更改config.username email
ssh对接的话可以不用
这也是为什么输入一次密码后即使不设置ssh下次push的时候也不用输入密码的原因