Skip to content

Commit bfcfdd4

Browse files
committed
lesson2: task: git workflow
1 parent 4e6a0db commit bfcfdd4

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

assignments/lesson2/.q23818.md.swp

-12 KB
Binary file not shown.

assignments/lesson2/.q23818.md.un~

2.16 KB
Binary file not shown.

assignments/lesson2/q23818.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,55 @@
2323

2424
## 4. Git命令使用过程总结
2525

26+
**一般开发协作流程**
27+
28+
### 1. 创建仓库,保持同步
29+
30+
根据仓库的来源,分两种情况:
31+
32+
- 如果是克隆仓库,直接用 `git clone`,不要手动初始化。
33+
- fork the repo
34+
- git clone remote-repo-url
35+
36+
- 如果是本地仓库关联远程,确保远程仓库是同一个项目的延续(而非全新的仓库)。
37+
先在本地git init,然后在远程创建好仓库,然后设置好关联,之后及时保持同步
38+
- git remote add origin remote-repo-url
39+
- 将本地仓库与远程仓库地址关联
40+
- git remote -v
41+
- 查看远程仓库在本地的name & url
42+
43+
44+
### 2. 在本地仓库,创建功能分支
45+
46+
`git checkout -b feature/your-feature-name`
47+
先切换到的项目目录,使用以下命令创建并切换到新分支:git checkout -b feature/your-feature-name
48+
创建新分支,才能提交代码更改,不能在原有分支上更改代码!
49+
50+
51+
### 3. 在本地仓库的功能分支,修改代码、提交
52+
在功能分支上进行开发后,您可以提交更改(将更改提交到本地):
53+
- `git add .`
54+
- `git commit -m "描述您的更改"`
55+
56+
### 4. 把本地分支的提交,推送到远程仓库,并创建pr
57+
- 将更改推送到您的Fork中:
58+
`git push origin feature/your-feature-name`
59+
- 会在fork中自动创建新的分支feature/your-feature-name
60+
`创建 Pull Request(PR)`
61+
62+
63+
### 5. 参与代码审查,合入PR
64+
65+
设为草稿:PR暂不会被合并,标题前会出现【WIP】,点击「准备就绪」可以取消草稿状态,点击「关闭」则可以关闭该PR。
66+
关闭PR:该PR不再需要被处理,同时也不会合并到主分支
67+
合入:提交的修改将会被合并入主分支
68+
69+
`fork --> clone --> checkout -b newbranch --> make change --> git add --> git commit --> git push --> pr`
70+
71+
### 6.为远程仓库配置个人访问token
72+
73+
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project. View existing forks.
74+
2675
(在此处总结使用Git命令的过程,包括但不限于以下操作:
2776
- git clone: 克隆远程仓库到本地
2877
- git add: 添加文件到暂存区

0 commit comments

Comments
 (0)