Home > Article > Backend Development > Detailed explanation of Git-the team quickly develops artifacts
I am a junior student at an undergraduate college. I have my own student team at the school. During project development, in order to improve development efficiency, I used Git technology. Now I’ll summarize git, everyone is welcome to communicate with each other.
|-master (master branch, synchronized with online code)
|-develop (development branch, after the function development is completed, it will be merged into develop first, and then develop will be merged into master)
|-feature (temporary branch (function branch), for example, to develop a certain function, you can create a new feature branch, and merge the feature branch into develop after completion)
|———— feature/update_online_pay_api
|———— feature/add_new_feature..
|———— …
|-release (temporary branch (pre-release branch), after development and testing, create a new release branch for testing, and merge it into master and develop after completion)
|———— release/update_online_pay_api
|———— …
|-hotfix (temporary branch (hot modification branch), generally used for emergency modification of short-term tasks such as bug branches, merged into master and develop after the modification is completed)
|————…
cd ~/workspace/git/ // 进入你个人的工作目录 mkdir project_name // 新建一个目录用于存放代码,名称可以和远程仓库名称一样 cd project_name // 进入你新建的目录 git init // 使用git初始化这个目录为一个git仓库 git remote add origin git@github.com:22th/oh-my-zsh.git // 关联本地仓库到一个远程仓库 git fetch --depth=1 // 更新远程仓库的一些信息到本地,比如分支信息等 git checkout -b master origin/master // 检出一个分支master并关联远程的master分支 git pull // 更新本地仓库代码Through the above process, you can synchronize the remote project to the local one. Now the default is the remote master branch. You cannot modify the code in the master branch. Generally speaking, you do not have this permission. After synchronizing the code to the local, you need to create a new development branch according to business needs. The name can be adjusted to suit your needs. For example, if you want to develop a new feature, then you create a feature-xxx branch. If you want to solve a bug, , you can build a hotfix-xxx branch. It is not recommended to create a new branch locally. You should create a new branch from the git warehouse management background and then check it out locally. Creating a new branch in the management background is very simple, so I won’t go into details.
Then you check your newly created branch locally, the command is as follows:
git checkout -b feature-xxx origin/feature-xxx
git add <file> // 将工作区修改添加到暂存区,加上 --all 参数表示将所有修改添加到暂存区 git commit -m “msg” // 将暂存区的修改添加到版本库 git push -u origin feature-xxx // 将本地仓库中的修改推送到远程 git status // 查看当前工作区间状态 git log // 查看历史commit git checkout -- <file> // 用最后一次commit的文件替换当前工作区间的文件 git reset --hard // 丢弃工作区间所有修改,回滚到上一个commit状态 git checkout <版本号> // 回滚到指定版本
<<<<<<< HEADln -s ../statics xxx =======ln -s ../statics statics >>>>>>> masterwhere «««. That is to say, if you want to keep your local code, then it is like this:
<<<<<<< HEAD (删除) ln -s ../statics xxx (保留) ======= (删除) ln -s ../statics statics (删除) >>>>>>> master (删除)
保留 «««git commit -am “解决冲突”。
3、好了,其他的工作就是运维人员来处理了。一般是这样的,release-xxx分支测试完成并解决所有冲突后,运维发布人员merge到master分支,然后通过 git d<a href="http://www.php.cn/wiki/109.html" target="_blank">if</a>f 608e120 4abe32e --name-only | xargs zip update.zip
命令打包差异文件,然后发布这个差异文件包就可以啦,不需要所有文件都覆盖线上文件。
到这里,整个git项目开发流程就已经非常清楚了。git还有很多高级功能,比如文件对比、文件历史修改记录、关联多个远程仓库等等需要你慢慢去摸索了。使用git要灵活运用分支,因为git新建切换分支的成本非常低,因为git新建分支不是想svn那样吧整个目录复制一遍,然后通过索引文件等更高级的方式来处理,效率高太多。
在推荐个git图形化管理工具:
source tree, mac和windows都有。
If you liked this article and think others should read it, please follow webff
The above is the detailed content of Detailed explanation of Git-the team quickly develops artifacts. For more information, please follow other related articles on the PHP Chinese website!