Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
280 views
in Technique[技术] by (71.8m points)

git - file grained vs line grained version control systems

What are some examples of version control systems that work on files and on lines of files?

In my understanding, a control system that works on file is able to automatically manage merges whenever there are no file conflicts:

for example:

A,B,C --> A',B',C
| (branch)  ___________ (merge) -> A',B',C'  
 -------> A,B,C'  

In what cases a version control system that work on lines is able to manage merge by itself and in what other cases it asks the developer to solve them?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your questions is too broad/generic but I'll try to give a shot anyways.

Most merge strategies in modern Version Control Systems, can't deal with the following:

Suppose you have files A B C in commit 001 in a repository.
Developer Dev1 branch of commit 001 and changes one line in file A, commits as 001a.
Developer Dev2 branch of commit 001 and changes the same line in file A and commits as 001b.

If someone wants to merge commits 001a and 001b, the merge system wouldn't be able to tell which is the correct change for the line, maybe the correct change for the project would be using the content in commit 001a or maybe the one in commit 001b, or maybe even mix of both changes in the line (that someone would have to create).

That's usually how you get a conflict that need manual intervention, because two developers are working in the same file and line and wrote different changes.

In the rest of the cases the result is obvious:

  • No changes in either commit? No changes in the merge result.
  • Changes in either of the commits? The change is applied in the merge.
  • Changes in the same file but different lines (for example, two devs working in different methods)? Both changes are applied in the merge.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...