What is the difference between commit and update in svn




















Before deciding how to attack a conflict interactively, odds are that you'd like to see exactly what is in conflict. Two of the commands available at the interactive conflict resolution prompt can assist you here.

The first line of the diff content shows the previous contents of the working copy the BASE revision , the next content line is your change, and the last content line is the change that was just received from the server usually the HEAD revision. Additionally, this command uses a slightly different display format for the conflict regions which allows you to more easily compare the file's contents in those regions as they would appear in each of three states: original and unedited; with your local changes applied and the server's conflicting changes ignored; and with only the server's incoming changes applied and your local, conflicting changes reverted.

After reviewing the information provided by these commands, you're ready to move on to the next action. There are several different ways to resolve conflicts interactively—two of which allow you to selectively merge and edit changes, the rest of which allow you to simply pick a version of the file and move along. If you decide that you don't need to merge any changes, but just want to accept one version of the file or the other, you can either choose your changes a.

Finally, there is also a pair of compromise options available. This may sound like an appropriate section for avoiding marital disagreements, but it's actually still about Subversion, so read on. If you're doing an update and encounter a conflict that you're not prepared to review or resolve, you can type p to postpone resolving a conflict on a file-by-file basis when you run svn update.

If you know in advance that you don't want to resolve any conflicts interactively, you can pass the --non-interactive option to svn update , and any file in conflict will be marked with a C automatically. When you postpone a conflict resolution, svn typically does three things to assist you in noticing and resolving that conflict:.

Subversion prints a C during the update and remembers that the file is in a state of conflict. Subversion uses the svn:mime-type property to decide whether a file is capable of contextual, line-based merging. For every conflicted file, Subversion places three extra unversioned files in your working copy:.

This is the file as it existed in your working copy before you began the update process. It contains any local modifications you had made to the file up to that point. If Subversion considers the file to be unmergeable, the.

This is the file as it existed in the BASE revision—that is, the unmodified revision of the file in your working copy before you began the update process—where OLDREV is that base revision number. This is the file that your Subversion client just received from the server via the update of your working copy, where NEWREV corresponds to the revision number to which you were updating HEAD , unless otherwise requested.

For example, Sally makes changes to the file sandwich. Meanwhile, Harry commits changes to that same file. Sally updates her working copy before committing and she gets a conflict, which she postpones:. At this point, Subversion will not allow Sally to commit the file sandwich.

If you've postponed a conflict, you need to resolve the conflict before Subversion will allow you to commit your changes.

You'll do this with the svn resolve command and one of several arguments to the --accept option. If you want to choose the version of the file that you last checked out before making your edits, choose the base argument. If you want to choose the version that contains only your edits, choose the mine-full argument. If you want to choose the version that your most recent update pulled from the server and thus discarding your edits entirely , choose the theirs-full argument.

Merging conflicts by hand can be quite intimidating the first time you attempt it, but with a little practice, it can become as easy as falling off a bike. Here's an example. Due to a miscommunication, you and Sally, your collaborator, both edit the file sandwich. Sally commits her changes, and when you go to update your working copy, you get a conflict and you're going to have to edit sandwich.

First, let's take a look at the file:. The strings of less-than signs, equals signs, and greater-than signs are conflict markers and are not part of the actual data in conflict. You generally want to ensure that those are removed from the file before your next commit. The text between the first two sets of markers is composed of the changes you made in the conflicting area:. The text between the second and third sets of conflict markers is the text from Sally's commit:.

Usually you won't want to just delete the conflict markers and Sally's changes—she's going to be awfully surprised when the sandwich arrives and it's not what she wanted. This is where you pick up the phone or walk across the office and explain to Sally that you can't get sauerkraut from an Italian deli. Now use svn resolve , and you're ready to commit your changes:.

Note that svn resolve , unlike most of the other commands we deal with in this chapter, requires that you explicitly list any filenames that you wish to resolve. In any case, you want to be careful and use svn resolve only when you're certain that you've fixed the conflict in your file—once the temporary files are removed, Subversion will let you commit the file even if it still contains conflict markers.

If you ever get confused while editing the conflicted file, you can always consult the three files that Subversion creates for you in your working copy—including your file as it was before you updated. You can even use a third-party interactive merging tool to examine those three files. If you decide that you want to throw out your changes and start your edits again whether this occurs after a conflict or anytime , just revert your changes:.

Note that when you revert a conflicted file, you don't have to use svn resolve. Your edits are finished, you've merged all changes from the server, and you're ready to commit your changes to the repository. The svn commit command sends all of your changes to the repository.

When you commit a change, you need to supply a log message describing your change. Your log message will be attached to the new revision you create.

If your log message is brief, you may wish to supply it on the command line using the --message -m option:. However, if you've been composing your log message in some other text file as you work, you may want to tell Subversion to get the message from that file by passing its filename as the value of the --file -F option:.

If you're in your editor writing a commit message and decide that you want to cancel your commit, you can just quit your editor without saving changes. If you've already saved your commit message, simply delete all the text, save again, and then abort:. The repository doesn't know or care whether your changes make any sense as a whole; it checks only to make sure nobody else has changed any of the same files that you did when you weren't looking. If somebody has done that, the entire commit will fail with a message informing you that one or more of your files are out of date:.

The exact wording of this error message depends on the network protocol and server you're using, but the idea is the same in all cases. At this point, you need to run svn update , deal with any merges or conflicts that result, and attempt your commit again.

That covers the basic work cycle for using Subversion. Subversion offers many other features that you can use to manage your repository and working copy, but most of your day-to-day use of Subversion will involve only the commands that we've discussed so far in this chapter.

We will, however, cover a few more commands that you'll use fairly often. You may continue to access the deleted item in previous revisions. You are reading Version Control with Subversion for Subversion 1. Fitzpatrick, and C. Michael Pilato. This work is licensed under the Creative Commons Attribution License v2.

Basic Work Cycle Prev Chapter 2. Basic Usage Next. Basic Work Cycle. Update Your Working Copy. Make Your Changes. Versioning Symbolic Links. Changing the Repository Without a Working Copy. Review Your Changes. Look Ma! No Network! See an overview of your changes. Tip Because the cvs status command's output was so noisy, and because cvs update not only performs an update, but also reports the status of your local changes, most CVS users have grown accustomed to using cvs update to report their changes.

File foo was U pdated received changes from the server. File or directory foo was A dded to your working copy. File or directory foo was D eleted from your working copy. File or directory foo was R eplaced in your working copy: foo was deleted, and a new item with the same name was added. Subversion considers them to be distinct objects. File foo changed in the repository, and you changed the local copy. Either the changes did not intersect, or the changes were exactly the same as your local modifications.

Subversion successfully mer G ed the repository's changes into the file. File foo received C onflicting changes from the server: The changes overlap your changes and need to be resolved by you; we explain how below. The C stands for conflict. You have to manually choose between your changes to bar. If Subversion considers the file to be mergeable i. For example, Sally changes the file sandwich.

Harry changes the file in his working copy and commits in. Sally updates her working copy before checking in and she gets a conflict:. Subversion will not allow you to commit the file sandwich. Support » Using Subversion » Subversion basics: using check out update , check in commit. In order to benefit from the features of Subversion, a project has to implement its workflow. When we cover Subversion basics, we start off with checking out and checking in. These are two vital parts which make collaborating through Subversion easy and efficient.



0コメント

  • 1000 / 1000