mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-08-01 16:28:03 +08:00
fix typo
This commit is contained in:
parent
7e46563e86
commit
f1119178c6
@ -164,7 +164,7 @@ Git 有三种状态,你的文件可能处于其中之一:
|
|||||||
|
|
||||||
### 远程仓库的移除与重命名
|
### 远程仓库的移除与重命名
|
||||||
|
|
||||||
- 将 test 重命名位 test1:`git remote rename test test1`
|
- 将 test 重命名为 test1:`git remote rename test test1`
|
||||||
- 移除远程仓库 test1:`git remote rm test1`
|
- 移除远程仓库 test1:`git remote rm test1`
|
||||||
|
|
||||||
### 查看提交历史
|
### 查看提交历史
|
||||||
@ -183,31 +183,30 @@ git log --author=bob
|
|||||||
|
|
||||||
有时候我们提交完了才发现漏掉了几个文件没有添加,或者提交信息写错了。 此时,可以运行带有 `--amend` 选项的提交命令尝试重新提交:
|
有时候我们提交完了才发现漏掉了几个文件没有添加,或者提交信息写错了。 此时,可以运行带有 `--amend` 选项的提交命令尝试重新提交:
|
||||||
|
|
||||||
```console
|
```shell
|
||||||
git commit --amend
|
git commit --amend
|
||||||
```
|
```
|
||||||
|
|
||||||
取消暂存的文件
|
取消暂存的文件
|
||||||
|
|
||||||
```console
|
```shell
|
||||||
git reset filename
|
git reset filename
|
||||||
```
|
```
|
||||||
|
|
||||||
撤消对文件的修改:
|
撤消对文件的修改:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
git checkout -- filename
|
git checkout -- filename
|
||||||
```
|
```
|
||||||
|
|
||||||
假如你想丢弃你在本地的所有改动与提交,可以到服务器上获取最新的版本历史,并将你本地主分支指向它:
|
假如你想丢弃你在本地的所有改动与提交,可以到服务器上获取最新的版本历史,并将你本地主分支指向它:
|
||||||
|
|
||||||
```
|
```shell
|
||||||
git fetch origin
|
git fetch origin
|
||||||
git reset --hard origin/master
|
git reset --hard origin/master
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 分支
|
### 分支
|
||||||
|
|
||||||
分支是用来将特性开发绝缘开来的。在你创建仓库的时候,*master* 是“默认的”分支。在其他分支上进行开发,完成后再将它们合并到主分支上。
|
分支是用来将特性开发绝缘开来的。在你创建仓库的时候,*master* 是“默认的”分支。在其他分支上进行开发,完成后再将它们合并到主分支上。
|
||||||
@ -216,13 +215,13 @@ git reset --hard origin/master
|
|||||||
|
|
||||||
创建一个名字叫做 test 的分支
|
创建一个名字叫做 test 的分支
|
||||||
|
|
||||||
```console
|
```shell
|
||||||
git branch test
|
git branch test
|
||||||
```
|
```
|
||||||
|
|
||||||
切换当前分支到 test(当你切换分支的时候,Git 会重置你的工作目录,使其看起来像回到了你在那个分支上最后一次提交的样子。 Git 会自动添加、删除、修改文件以确保此时你的工作目录和这个分支最后一次提交时的样子一模一样)
|
切换当前分支到 test(当你切换分支的时候,Git 会重置你的工作目录,使其看起来像回到了你在那个分支上最后一次提交的样子。 Git 会自动添加、删除、修改文件以确保此时你的工作目录和这个分支最后一次提交时的样子一模一样)
|
||||||
|
|
||||||
```console
|
```shell
|
||||||
git checkout test
|
git checkout test
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -232,31 +231,31 @@ git checkout test
|
|||||||
|
|
||||||
你也可以直接这样创建分支并切换过去(上面两条命令的合写)
|
你也可以直接这样创建分支并切换过去(上面两条命令的合写)
|
||||||
|
|
||||||
```console
|
```shell
|
||||||
git checkout -b feature_x
|
git checkout -b feature_x
|
||||||
```
|
```
|
||||||
|
|
||||||
切换到主分支
|
切换到主分支
|
||||||
|
|
||||||
```
|
```shell
|
||||||
git checkout master
|
git checkout master
|
||||||
```
|
```
|
||||||
|
|
||||||
合并分支(可能会有冲突)
|
合并分支(可能会有冲突)
|
||||||
|
|
||||||
```java
|
```shell
|
||||||
git merge test
|
git merge test
|
||||||
```
|
```
|
||||||
|
|
||||||
把新建的分支删掉
|
把新建的分支删掉
|
||||||
|
|
||||||
```
|
```shell
|
||||||
git branch -d feature_x
|
git branch -d feature_x
|
||||||
```
|
```
|
||||||
|
|
||||||
将分支推送到远端仓库(推送成功后其他人可见):
|
将分支推送到远端仓库(推送成功后其他人可见):
|
||||||
|
|
||||||
```
|
```shell
|
||||||
git push origin
|
git push origin
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user