Git project learning --03- (use rebase the multiplayer co-development workflow: Git Flow of use procedure, put on-line measurement (pre-release), Git additional knowledge: profile, avoid close login, Git ignore file) ( Key)

1, fox

rebase submit records can be kept simple, not forked.

创建新文件
touch 文件名.文件类型
例:touch 1.py


创建新文件夹
mkdir 文件夹名称

清屏快捷键
ctrl+L

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Modifications are complete, the detection results are as follows:
Here Insert Picture Description

2, multiplayer co-development workflow: Git Flow

2.1 & invite members to create a project
when collaborative development requires all members can operate on the same project, you need to invite members and to give permission or can not be developed. github supports two ways to create a project (for multiplayer co-development).

  • 1. After collaborator, add users to the warehouse collaborators, the user can submit code to the current repository.
  • 2. organization, will invite members into the organization, you can create multiple warehouses under the organization, members can submit code to the organization at the warehouse.

2.2 Development members
registered Github account or Gitlab

  • Invite members to the organization (the default has read access to the organization's project)
  • Invite members to become partners in a project

Here Insert Picture Description
Creating organizational success is shown below:
Here Insert Picture Description

Here Insert Picture Description
After completion of the above interface refresh github:
Here Insert Picture Description

创建标签
git tag -a 版本代称 -m "xxx描述信息"
例如:git tag -a v1 -m "xxx"

将标签推送上去
git push 用户名 --tags
例如:git push origin --tags

创建并切换至当前分支
git checkout -b 分支名称
例如:git checkout -b dev

Here Insert Picture Description
Now the project has been completed the preparatory work, the latter can invite members to develop:

Here Insert Picture Description
Here Insert Picture Description
Git Flow from the main operation flow of the developer is as follows :( can add people) from developer
Here Insert Picture Description
2.3 code review

  • Configuration, after the code review can be incorporated into the dev branch
  • Members to submit code review application
  • Leader to do code review

code review setting:
Here Insert Picture Description
Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description

3, summary Git Flow of use procedure

  1. Create github tissue
    Here Insert Picture Description
    steps behind the skip is not provided;
    Here Insert Picture Description
  2. Create a new project folder, distinguish between different developers folders, upload files to the foundation to develop code github, allow other developers to download and update new features;
$ git init       # 初始化

$ touch app.py     # 创建基础的代码文件

$ git add .        # 提交至git管理

$ git commit -m "基础的app版本开发"      # 添加描述信息

$ git remote add origin https://github.com/github-test-project-0/test_project.git    # 推送至github账户

$ git push -u origin master                     

$ git tag -a 基础版本 -m "第一版app"            # 创建tag

$ git push origin --tags                       # 上传tag

Here Insert Picture Description
After doing the above steps, you can see the screen refresh github app.py file upload and tag labels.
Here Insert Picture Description
3. Create master_projecter_dev branches, switch to the current branch, and pushed to GitHub, this is a test for a later version of the code combined branch lines;

git checkout -b master_projecter_dev   # 创建在主开发人员下的新分支,用于以后测试合并的代码版本的分支线

git push origin master_projecter_dev

Here Insert Picture Description
Then add permission from the developers, setting on github interface set developer account and permission information (inviting members and set permissions have completed the next step in FIG. 4) from when invited to complete from the time developers, they github bound mail will receive a verification e-mail, you need to click OK to join the organization to develop.
Here Insert Picture Description
4. Create a file from the developer's folder, and download the basic code files uploaded github, created from the branch slaver_projecter_dev developers, after the completion of part of the code, uploaded to github.

git clone https://github.com/github-test-project-0/test_project.git     # 从github上面下载之前的app基础文件

ls                           # 当前路径下的文件

cd test_project/             # 转到改路径下

git checkout -b slaver_projecter_dev             # 创建并转换至当前分支slaver_projecter_dev

git branch                                      # 切换分支

touch new_app.py                               # 创建新的代码文件,并开始编写从开发人员负责的功能模块

git add .                                      # 提交至git

git commit -m "app新功能开发了50%"              # 添加描述信息

git push origin slaver_projecter_dev            # 上传当前分支的信息到github上

Here Insert Picture Description
Continue to complete some of the features of the code files from the developer until the upload;
Here Insert Picture Description
5. Project Leader need to set code review rules: The number of consolidated branch name, etc.
Here Insert Picture Description
Here Insert Picture Description

6. Merge branch file, first click on the figure below New pull request
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
back to the main program interface, you can see the merged file in master_projecter_dev:
Here Insert Picture Description
7. Different companies may have additional project operation is: testers needed for app developers to test the code, this time need to create a test folder, download the complete code files for testing, collecting bug, upload bug:

git clone https://github.com/github-test-project-0/test_project.git   # 从github上面下载基础代码文件
ls

cd test_project/             # 转到下载的代码文件夹下
ls

git checkout master_projecter_dev   # 切换到上一步code review合并后的代码文件分支上
ls
cat new_app.py    # 测试完整最新的代码文件,收集bug,并上报

Here Insert Picture Description
8. In the main developer of the file folder, the code has not been updated to the latest file, you need to download the file after the merger on github:

ls

git pull origin master_projecter_dev            # 将code review后合并的代码文件下载到本地文件夹下
ls

cat new_app.py

git checkout master                           

git merge master_projecter_dev                 # 切换回master分支后合并代码文件
ls

git push origin master                  # 更新到github上

Here Insert Picture Description
When the code files on the master branch update on github, posting the code developed and APP.

4, put on the measuring line (pre-release)

Performed by a dedicated team or team leader following steps
1. Create a release branch based on the branch master_projecter_dev

git checkout master_projecter_dev

git checkout -b release

2. testing

3. Merge to master

使用 pull request

本地将release合并到master分支

4. playing tag in the master branch

git tag -a v2 -m '第二版 xxx功能'

git push origin --tags 

The operation and maintenance personnel to download the code can cook the line

git clone -b v2 地址

To contribute code to the open source project

  • 1.fork source code will copy the source code to others my own remote repository.
  • 2. Modify the code in their own warehouse
  • 3. On to the source code of the application submitted bug fixes (pull request)

Find someone else's project, after entering, click Fork: then it will download onto your github:
Here Insert Picture Description
start the download from their account to the local github:

git clone xxxx自己github项目地址xxxx

Then modify the file in the local folder for the project, modify, update and other operations; submit to on github, operating and code review before the introduction of the same.

5, Git additional knowledge

Configuration files are stored three locations

  • Project profile: Project /.git/config
git config --local user.name 'xxx'
git config --local user.email 'xxxx@xx.com

Here Insert Picture Description

  • Global configuration file: ~ / .gitconfig
git config --global user.name 'xxx'
git config --global user.name 'xxx@xx.com

Here Insert Picture Description

  • System configuration file: /etc/.gitconfig
git config --system user.name 'juran'
git config --system user.name '[email protected]'
注意:需要有root权限

Free Password

Reflect the URL

原来的地址:https://github.com/WuPeiqi/dbhot.git
修改的地址:https://用户名:密码@github.com/WuPeiqi/dbhot.git
git remote add origin https://用户名:密码@github.com/WuPeiqi/dbhot.git 
git push origin master

SSH implementation (focus)

1.生成公钥和私钥(默认放在~/.ssh目录下,id_rsa.pub公钥、id_rsa私钥) ssh-keygen

2.拷贝公钥的内容,并设置到github中。 

3.在git本地中配置ssh地址
git remote add origin git@github.com:WuPeiqi/dbhot.git

4.以后使用
git push origin master

Here Insert Picture Description
The following screen shows the success of settings:
Here Insert Picture Description

git ignore file

Let Git no longer manage some files in the current directory.

*.h    
!a.h  
files/  
*.py[c|a|d]

Reference: https: //github.com/github/gitignore

Effects are as follows:
Here Insert Picture Description
Added .py files, .h files and .py [a | b | c] file; ignore these types of files of state
Here Insert Picture Description
Here Insert Picture Description
related task management github

  • issues, document and task management.
  • wiki, project documentation.
Published 60 original articles · won praise 9 · views 5036

Guess you like

Origin blog.csdn.net/weixin_42118531/article/details/104891971