67 lines
3.0 KiB
Markdown
67 lines
3.0 KiB
Markdown
### 1.git安装教程
|
||
|
||
教程链接:<a href="https://zhuanlan.zhihu.com/p/443527549">https://zhuanlan.zhihu.com/p/443527549</a>
|
||
|
||
### <font color = "red">2.git基本操作命令</font>
|
||
|
||
#### 2.1 git常用命令
|
||
|
||
> - git init 初始化项目
|
||
> - git status 查看当前目录下文件的状态
|
||
> - git add (文件名 | .)添加到暂存盘,文件名代表某文件,"."代表所有文件
|
||
> - git commit -m "备注" 提交到git本地仓库,产生新版本,引号中的备注必须写
|
||
> - git log 查看所有提交的记录
|
||
> - git clone 链接 克隆远程仓库,进行连接
|
||
> - git checkout -b [branch] 新建一个分支,并切换到该分支
|
||
> - git checkout [branch] 切换到某分支
|
||
> - git branch -d [branch-name] 删除分支
|
||
> - git merge [branch] 合并指定分支到当前分支
|
||
> - git push 将本地仓库push到远程仓库
|
||
|
||
#### 2.2 流程详解
|
||
|
||
1.打开想要上传项目的文件根目录,右击Git Bash Here,输入命令 **git init**:
|
||
|
||
``` $ git init ```
|
||
|
||

|
||
|
||
发现在根目录中出现了一个 **.git** 文件,表明此项目已被git管理。
|
||
|
||
2.通过` git clone "仓库链接"`与远程仓库进行连接:
|
||
|
||

|
||
|
||
3. 连接成功后,添加项目到暂存区,并提交项目到本地仓库,中间可以使用 **git status** 命令查看文件状态:
|
||
|
||
当使用用` git status` 查看状态显示“没有需要提交的,工作树干净”时,就说明项目已经全部提交至本地仓库。
|
||
|
||
4. 使用命令 `git checkout -b dev` 创建dev分支并切换到该分支下,在分支上进行操作;在这之前或之后都可以使用命令 `git branch` 查看仓库的分支都有哪些
|
||
|
||
5. 操作这么多命令后,可能已经断开了与远程的连接,使用命令 `git remote -v`查看,如果为空,则使用 `git remote add origin 链接` 再次与远程仓库进行连接
|
||
|
||
出现如上图所示,则重新连接成功!
|
||
|
||
6. 把master分支合并到dev分支,进行add和commit,最后push到远程
|
||
|
||
7. 查看项目是否上传成功。
|
||
|
||
### <font color="red">beyond compare 解决冲突</font>
|
||
|
||
1. 安装beyond compare
|
||
|
||
2. 在git 仓库中配置
|
||
|
||
```
|
||
git config --local merge.tool bc4
|
||
git config --local mergetool.path 软件安装目录
|
||
git config --local mergetool.keepBackup false
|
||
```
|
||
|
||
3. 应用bc 解决冲突
|
||
|
||
```
|
||
git mergetool
|
||
```
|
||
|
||
|