Small team git development model

Source: Internet
Author: User
Tags diff time interval using git git clone

The lab is using Git for code management, but git is very complex and the development patterns are endless. It's very embarrassing to be a novice. Search the web and find that many of them are not suitable for our small team (which is itself a distributed code management tool developed for Linux kernel management). About the difference between distributed and centralized (SVN) code management You can search by yourself, there is no more to say.

The web finds git's Chinese material, mostly about the use of Git's commands, and little about Git's workflow and how to achieve teamwork, especially with the team code Base manager's documentation. Even if there is also come up to talk about a variety of branch xxxx, a little dizzy. Here's one of the simplest and most primitive ways to work with Git for team development. Introduction to the pattern:

The diagram below is a simple team collaboration pattern:



The development process for this pattern is as follows:

1, by one of the developers on this server to establish a database. All developers can submit and download things to the database, there must be a certain time interval (a week or a day) must be submitted once, or later resolve the conflict is a big problem. If everyone's development coupling is high, we can set up a branch on the server, then each person submits to their branch, after a period of time (not too long) a person to merge branches. Everyone then updates the master branch of their database to synchronize with the Master branch on the server.
2, so the server will have a lot of version information, a collection of everyone's version information. After a period of time, for example, a milestone appears. Then a person to patch all the changes to the final server. This will make the final server version information very concise.
3, when our server unlimited expansion to a certain extent, we can delete it, and then use a version of the final server as the starting version. Here we begin to practice :
1. Git Server Setup

If you have fewer people using git, you can use the following procedure to quickly deploy a git server environment:

http://www.haijd.net/article/index.php?action=read&id=840

The simplest without any security control is to install a. Git on the server, as follows:

$ cd/opt/git
$ mkdir project.git
$ cd project.git
$ git–bare Init

Where the server is built, the developer can add it as a remote warehouse, push a branch, and upload the first version of the project to the warehouse. It is worth noting that each time you add a new project, you need to log in to the host through the shell and create a pure warehouse. We might as well use WST as the host name for git server users and warehouses. All of the following commands are available:

# on a developer's computer

$ CD MyProject

$ git init

$ git Add. #这里选择你需要添加的文件

$ git commit-m ' initial commit '

$ git Remote add Origin wst@192.168.88.46:/home/wst/wanghanbo/wireshark.git

$ GIT push origin master

This way, the GIT server has the first initial code version. 2. Developer Extraction Code

Here are the other participating developers to install Git first and then set the username and mailbox:

git config--global user.name "My Name"

git config--global user.email "my@email.co then clones the code from the code base:

$ git clone

Wst@192.168.88.46:/home/wst/wanghanbo/wireshark.git

In this way, each participating team member also has the first code that is consistent with the code base version.

3. The operation in development

Now, we're going to start developing. can refer to

http://blog.enjoyrails.com/2008/12/31/git%E4%B8%80%E5%88%86%E9%92%9F%E6%95%99%E7%A8%8B/

first let's look at how to update the local code to the latest version:

The first method uses fetch (the merge is required to fit into the local code)

Git fetch Origin Master:temp
Git merge temp #合并更新到temp分支的代码到本地代码库的master分支中

Another way to update your code (GIT pull is a combination of the Git fetch and git merge commands)

Git pull Origin Master

Resolve code conflict issues

Note: when the merge command itself is unable to resolve the conflict, it places the work tree in a special state and gives the user conflicting information, so that the user can solve the problem on their own. At this point, of course, no conflicting code has been registered in the index file by git merge. If you use git diffat this time, only the conflicting code information is displayed.

Before you resolve the conflict, the conflicting files will always be flagged in the index file. This time, if you use Git commit, Git will prompt: filename.txt needs merge. In the event of a conflict, if you use the git status command, you will show specific information about the conflict.

After resolving the conflict, you need to commit:

git commit #将已经解决冲突的代码提交到本地代码库
Git branch-d temp #删除temp分支

To create a new branch and develop it locally:

GIT branch Development #搞个development分支给自己开发

git checkout development #切换至development分支进行开发

The development of XXXX process, confirm the function development completed, can inherit to the complete system when running:

git checkout Master #切换至master分支

git merge Development #合并development及master分支

After you modify the code, view the modified content:

View the modified content

git diff--cached

Add new additions to Git

git add file1 file2 file3

You can set the ignored criteria:

The simplest method creates a file in the same location as the. Git directory in the project root directory:. Gitignore

#
# note! Don ' t add files that are generated into specific
# subdirectories here. Add them in the ". Gitignore" file
# subdirectory instead.
#
# note! Please use ' git ls-files-i--exclude-standard '
# command over changing this file, to the If there are
# any TRAC ked files which get ignored on the change.
# #
Normal rules
#
. *
*.o
*.o.*
*.a
*.s
*.ko
*.so *.so.dbg *.MOD.C
*.i
*.lst
*.symtypes
*.order
modules.builtin *.elf *.bin *.gz
*.bz2
*.lzma
*.lzo
*.patch
*.gcno
 
# top-level
files
#
Tags
/tags
/linux
/vmlinux
/vmlinuz
/system.map
/module.markers
/ Module.symvers
 
#
git files we don ' t want to ignore even it they are dot-files
#
!. Gitignore
!. Mailmap # #
generated include files
#
include/config
include/linux/version.h
include/generated
 
# Stgit generated dirs
patches-*
 
# quilt ' s files
Patches
Series
 
# Cscope files
cscope.*
ncscope.*
 
# GNU global files
gpath
grtags
gsyms gtags
 
*.orig
*~
\#*#
can see:

http://www.code007.org/?p=291

Http://www.cnblogs.com/wucg/archive/2011/08/16/2141647.html

To delete a file from git:

git rm file1
git rm-r dir1

Commit modification to local code base

Git commit-m ' This is Memo '

If you want to omit the git add command before submitting it, you can use the

Git commit-a-M ' Is memo '

The difference between commit and commit-a, Commit-a is equivalent to: 1. Automatically add all changes to the code, so that all the development code is listed in the index file; 2. Automatically delete files in index file but not in the work tree 3. Execute the commit command to submit to the local code base.

commit all modifications to the remote server

Check out the server's code first, match the current code, and modify the conflict.

Git fetch Origin master:temp #跟git代码库fetch到一个temp分支
Git merge temp #保证代码是最新的.

After resolving the conflict, you need to commit:

git commit #将已经解决冲突的代码提交到本地代码库
Git branch-d temp #删除temp分支

After conflict resolution

After committing to a remote git server, other team members will be able to update these modifications (because we are still using centralized management, where each developer checks out the update from the GIT server)

Git push Origin Master

Want to revert to a version of code or undo an action

Rollback code:

git revert head

You can also revert earlier commits.

For example: git revert head^

To revert to a version of the code, use this git reset command:

Git reset back to previous version
----Mixed is the default option for Git-reset, which is to reset the indexed content and position it to the specified project version without changing everything in your work tree, just to indicate which files have not been updated.
The--soft option neither touches the location of the index nor changes anything in the working tree. This option preserves all updates that you have in the working tree and makes them in the pending state. Equivalent to adding git add on a--mixed basis.
--hard restores the entire directory to a version, including all files.

Read MORE: http://blog.sina.com.cn/s/blog_68af3f090100rp5r.html

At present, the end of the code server, we put aside for a while. Of course, if you want to implement it, you can build another xx.git. In the code library before the same as the engineer down the past can ~ ~ ~ Rest, Rest ~ ~






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.