Git小记

作者: 灯花微凉 | 来源:发表于2019-05-22 00:39 被阅读70次

1、Git下载与安装

https://git-scm.com 选择对应macOS系统的版本进行安装;

2、Git初始化

打开终端,进入项目文件夹目录,使用命令 git init 初始化git仓库;

3、远程仓库——GitHub

https://github.com 访问GitHub主页进行注册;

创建远程仓库

新建远程仓库

4、创建SSH密钥关联远程仓库

打开本机终端,输入命令 ssh-Keygen 后三次回车,进入~/.ssh目录复制id_rsa.pub文件中内容到GitHub中

设置 ssh配置页 将密钥粘贴到这里

打开本机命令行,配置用户及邮箱

git config --global user.name 'xxx'

git config --global user.email xxx@xxx.com

查看git配置

git config --list

本地分支关联远程仓库

拷贝远程分支的仓库地址

拷贝远程仓库地址

git remote add origin https://github.com/xxx/xxx.git

5、Git工作流程图

git工作流程图 命令流程

6、Git基本指令

查看远程仓库    git remote -v

添加本地仓库地址为远程仓库    git remote add <name> <remote>

远程仓库重命名    git remote rename <old_name> <new_name>

克隆仓库    git clone <repository>

查看文件状态    git status

提交到暂存区    git add <src_path>

提交到本地仓库    git commit -m 'xxxxxx'

提交到远程仓库    git push <remote> <branch>

撤销工作区修改    git checkout --<file>

暂存区文件撤销,不覆盖工作区    git reset HEAD <file>

版本回退    git reset --(soft | mixed | hard) <commitID>

比较工作区与暂存区    git diff

比较工作区与本地库中最近一次内容    git diff HEAD

比较暂存区与本地库中最近一次内容    git diff --cached

比较两次提交到差异    git diff <commitID1> <commitID2>

查看日志    git log -p <file_name>

查看历史操作记录    git reflog -p

查看分支    git branch

新建分支    git branch <branch_name>

切换分支    git checkout <branch_name>

创建并切换分支    git checkout -b <branch_name>

删除本地分支    git branch -d <branch_name>

删除远程分支    git push -d <origin> <branch_name>

无冲突合并分支    git merge <branch_name>

有冲突合并    git merge <branch_name>    git add <file_path>    git commit -m 'xxxxxx'

命令大全    git help -a

命令帮助    git help <command>

相关文章

  • Git 教程(命令行)

    Git命令小记 分支 1、创建本地分支 local_branch $ git branch

  • Git 设置.gitignore 不生效的解决办法

    git学习使用小记 @(Alu)打开git命令行:输入: 清除git的本地版本库缓存再输入: 将你的 .gitig...

  • git 代码版本管理工具add、commit、pull、push

    接触git版本管理工具有一段时间了,工作中使用到git,特此小记git代码版本管理工具add、commit、pul...

  • git 小记

    删除暂存区的文件夹,(node_modules)为要被删除的文件夹 refusing to merge unrel...

  • Git 小记

    介绍 Git是一个软件版本控制管理的一种机制和实现,类似的还有:SVN, Mercurial;更详细的可以参见维基...

  • Git 小记

    error:create branch Fatal: Not a gitflow-enabled repo yet...

  • Git小记

    最近在使用Git,把自己这一段时间对Git的一些理解与困惑记录下来,以便自己回顾,如果能够帮助到别的网友那么也是极...

  • GIT小记

    开始使用Git来进行版本控制,常用命令如下: git init creates a new Git reposit...

  • Git 小记

    记录Git常用的一些操作 初始化仓库 git init 添加文件 git add filename 单个文件git...

  • git小记

    Git配置 查看用户名和邮箱 没有add 之前 回滚 add 之后回滚 查看远程分支 git pull 比如,要...

网友评论

    本文标题:Git小记

    本文链接:https://www.haomeiwen.com/subject/ayqezqtx.html