git common commands and programs involved in the process step of analyzing in the project

GIT

Git consisting of: a distributed version control software

svnIt is a centralized version control, and gitis distributed version control

  • Ask price copy
  • Local Version Control
  • Centralized version control
  • Distributed Version Control
The first stage: build version, extensions, version rollback

command:

1.git init ----- 初始化生成.git文件进行管理
2.git status  ------检测当前文件的文件状态,也显示当前文件夹内的文件名称,管理后的文件是绿色,未管理的是红色,也可以进行文件检测,检测文件是否被修改,如若修改则直接变成红色.
3.git add 文件名称  ---- 进行管理文件
4.git add .   ----管理当前文件夹所有未管理的文件
5.git log   -----查看版本记录
6.git  --version  ------检查版本号
7.git commit -m "描述信息"-----生成版本

git three regions:

工作区:
1.已经管理的和修改/新增文件
暂存区:git add .  表示把工作区文件提交到暂存区
版本库:git commit  表示把暂存区文件提交到版本库

Rollback:

git reset --hard  版本号
git reflog  ------用于查看的所有的操作及版本过程

Scheduling the work area:

git checkout -- <file>  修改文件变成管理文件,剔除修改内容
git reset HEAD <file>  ---把问价从暂存区返回到工作区

The second stage: branch

When online the BUG, ​​create branches repair BUG, ​​and then merged into the main branch.

git branch  ----- 用户所处在的分支
git branch dev   ---- 创建新分支dev
git checkout dev  ---切换到dev分支
git merge dev   ---合并分支dev到master主分支
CONFLICT (content): Merge conflict in git_tes/templates/index.html
可能会带有冲突,这时须手动解决.
git status ----查看改动
git commit -m "备注"
英文状态下q表示退出
git branch -d 分支名  ----删除分支

Workflow

不在master分支上开发

github: code repository, gitlab

1.注册账号
2.创建仓库
3.本地代码推送远程仓库

github do code hosting

1.创建仓库
2.推送代码
git remote add origin https://github.com/PythonerIron/gittest0912.git
git push -u origin master
也可以推送其他的分支
git push -u origin dev
3.克隆代码
git clone https://github.com/PythonerIron/gittest0912.git
已经clone了所有分支,但是只显示master分支,可以直接Git checkout dev进行操作

How to develop?

1.创建分支dev
2.切换到dev分支
3.将master分支代码复制git merge master
4.进行开发 touch a1.py
5.git add. 
6.git commit -m "01day"本地生成控制版本
7.git push -u origin dev
8.回家继续,远端更新 
9.git checkout dev
10.git pull origin dev
11.开发,提交代码
git pull origin dev 等价于
git fetch origin dev
git merge origin/dev

rebase (变基)

#将多个记录整合成一个记录
1.git rebase -i  版本号-----将最新的版本号和当前rebase后的版本号之间合并.
2.git rebase -i HEAD~3   整合三条
注意:合并是不要合并已经push的文件

#分支合
git log --graph --pretty=format:"%h %s"画图式显示
*   f52d0b5 Merge branch 'master' into dev
|\
| * a050c14 master test01
* | f408a0f dev test
|/
* 4ecd59b dev new.py
* 27ca536 dev分支上线
* 7a4e949 04
* 885d61d 03
* 94ed499 02
* 1a87782 01
分支合并,在dev merge master,然后在master merge dev


#分叉
家:v2   公司:v1  如若在公司拉代码v2会造成分叉,此时,
git fetch origin dev
git rebase origin/dev


#注意事项:git rebase产生冲突,解决冲突
git  add .
git rebase --continue

beyond compare file compare, quick resolution of the conflict

在git中配置
git config --local merge.tool 名字bc3
git config --local mergetool.path '安装目录E:\Beyond Compare 4'
git config --local mergetool.keepBackup false
应用beyond compare解决冲突
git mergetool

How many people develop?

每个人都有自己的分支上进行开发,然后没两天就要合并一下处理冲突.

Check the codereview

gitflowWorkflow

tag (tagging) to tag the master branch

git tag -a v1 -m "第一版本"------版本v1  和版本的信息描述
git push origin  --tags   -----将版本推送到github
创建dev并且切换到dev分支
git checkout -b dev 这是已经在自己的电脑上了
还需要将自己本地的代码推送到远程,github才会显示这个分支
git push origin dev

githubPermissions organizationssettings

默认是只读
开发人员克隆代码
git clone 地址
在dev分支上继续开一个分支
开发完成时,需要代码review

Testing process

git checkout -b release
git push origin release
git branch -d release  删除release分支

Operation and maintenance personnel to download the code line cook

git clone -b v2 地址

How to contribute their strength in open source code

1.在github中fork待贡献代码
2.类似于二次开发,在自己的仓库进行修改
3.给源代码作者提交修复bug的申请

Profiles

配置用户名和密码

1.在当前的项目生效,在其他的项目就不生效
    项目的配置文件在.git/config
git config --local user.name 'ashley"
git config --local user.email "[email protected]"
2.全局配置文件,所有的项目均可通用
    项目文件配置在 ~/.gitconfig
git config --global user.name 'ashley"
git config --global user.email "[email protected]"
3.系统配置文件,需要有root权限
    项目文件配置在 /etc/.gitconfig
git config --system user.name 'ashley"
git config --system user.email "[email protected]"

Avoid close Login

1.URl实现
原来的地址:https://github.com/Qingdaodianye/QD-.git
免密登录:https://用户名:密码@github.com/Qingdaodianye/QD-.git
2.通过ssh实现
ssh地址:[email protected]:Qingdaodianye/QD-.git
    2.1自己生成公钥和私钥,默认声称在当前根目录下的~/.ssh/id_rsa.pub(公钥)和id_rsa(私钥)
    ssh-keygen
    2.2拷贝公钥内容设置在github的settings中
    2.3在git本地中配置ssh地址
    git remote add origin [email protected]:Qingdaodianye/QD-.git

git ignore file

When met do not want the file to be managed, we should ignore such files

1.创建.gitignore文件
vim .gitignore
写入不需要管理的文件名例如a.py
也可以写入自己.gitignore
2.
*.h
!a.h
files/
*.py[c/d/ds]

Task Management

  • issues

    A summary of the problem, to avoid duplication of answers, there are bug management

  • wiki

    There are new people coming in to facilitate understanding of the project to write a number of projects related to things like document for later

Guess you like

Origin www.cnblogs.com/Zhao159461/p/11517478.html