1

I'm very new to SCM, and I'm aware that there are some guidlines and recomendations to follow , but I'm not aware of any of them. There are several things that keeps me confused about SCM. For example:

  1. I know that it's a best practice to commit as soon as possible and as often as possible, but what should I do, if I'm working on a change/feature that requires several days or even weeks? I could split the task but, mercurial says that one should never commit change with future change in mind. Every change in commit should be in final stage.
  2. In what situations are branches useful? except splitting different releases in SCM.
  3. Why and when should I clone a repository?

Sorry for those dumb questions and my broken English, I read many articles about SCM on the net, but every of them contains conflicting information for each other.

Thanks

1
  • You can also ask such on the project mailinglist: [email protected] There we can have a discussion about them. Stack Overflow is better for questions of the form "How do I do X?", not "When or why should I do X?". Commented Mar 29, 2012 at 12:07

1 Answer 1

2
  1. Commit when something logical is done or you need to perform an action on the branch. Push when you have confirmed the code is good via unit tests. Commits are local, pushes are public.
  2. Branch when you are about to start something that requires several days or even weeks :-)
  3. Clone when you need to, there are no best practice rules around it.

The mindset isn't about committing often, it is more about merging often. If you are on a branch, merge with the mainline frequently. Smaller chunks are easier to digest and you can keep visibility on what is developing (to adjust your code accordingly).

Sign up to request clarification or add additional context in comments.

10 Comments

thank you very much for your response. There's still one thing I don't get. You say that I should create a branch when a feature requires several weeks of work. Why should I work with the branch and not with main repository? How should I work with the branch, can I commit unfinished changes to that branch and when it is finished, I will merge with main repository and push only the finished changesets (from main repository)? This is what you meant? And if so, the newly created branch will be pushed also? Thanks again :-)
The way I work is I create a branch adjacent to main to do some involved work, this means I can have the main branch keeping pace with the rest of development and merge from it into my named branch whenever I like. When I'm done, I'll do one final merge from main to named, then a no-op merge from named to main (no-op because I've already done the merge the other way). When you push, you can then push everything or just the one changeset that you merged from named into main.
sorry for the dumb question, but what does no-op merge means. As you already have guessed, I'm completely new in this area :(. And what concerns branching, if I understand correctly, when I need to do some heavy work, I create a branch to some dirty work in it, when I have some progress I can merge the latest changeset to main branch. When I'm finished with this "heavy work", I merge main repo in named one (so later I will avoid merge conflicts) and after that, I merge the latest changeset from named branch to main one. And about pushing, what's best, to push only last changeset or
Everything? Thank you again adam for your time :)
@Davita You won't have much choice on pushing, the server will state what of your changesets it doesn't have, so most of the time you push everything. By a no-op merge I meant that if you merge from default into your branch, then when you come to merge from your branch into default you won't get any conflicts and the merge will "just work".
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.