git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Really beginner on Version Control

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Sep 22, 2010, 22:10 UTC
Message-ID
<AANLkTi=4qdjicBZs=yPWmAu5B+GePQeTpOr80PBi3+29@mail.gmail.com>
In-Reply-To
<1285080133451-5555023.post@n2.nabble.com>

On Tue, Sep 21, 2010 at 6:42 PM, FernandoBasso <FernandoBasso.br@gmail.com> wrote:

>
> Why do we merge, say a testing branch into the master branch ? What is the
> use of it ?

We usually don't do that, because it goes against recommended git workflows http://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html

With Git, you typically merge your stable branch to to your main development branch or you merge some feature branch to master if you consider it to be mature enough to be included in the next release.

> When there is a conflict when merging branches (merging the testing into the
> current branch), should I edit the 'current' branch or the 'testing' branch

You edit files in your working directory to resolve conflicts, after you commit the result to your current branch.

> Should both branches have exactly the same code so that they can be merged
> without conflicts ?

No... There are different merging strategies, and Git is flexible enough to allow you to specify your own merging strategy for some files. The default merging strategy relies on the context to find if there is any conflict. It means that the same file has been edited around the same place (around the same line), then it will generate a conflict.

There is one important thing to keep in mind when it comes to merges. Merge conflict are your friends and not your enemies. In other words, they warn you about changes to some files that can contradict each other, so you need to use your brain to resolve them gracefully. Usually, they do pretty good job at that, but in some rare cases, merge without any merge conflict can produce unworkable code. So, after any non-trivial merge, you should do testing. If testing reveals some problem then you should correct them. Git allows you amend any last commit (including the merge commit) using:

git commit --amend

If two branches are diverged a long time ago, it is very useful to look at history of those branches to find what changes caused the conflict. You can do that using the following command:

gitk --merge
or if you are interested only in one particular file then:
gitk --merge this-file
Dmitry
Previous: Dmitry Potapov
Message 17 of 17 in “Really beginner on Version Control”
  1. FernandoBassoSep 21, 2010
  2. Thomas MoulardSep 21, 2010
  3. Enrico WeigeltSep 21, 2010
  4. Eric RaibleSep 24, 2010
  5. Enrico WeigeltSep 24, 2010
  6. FernandoBassoSep 24, 2010
  7. Andreas EricssonSep 21, 2010
  8. Jakub NarebskiSep 21, 2010
  9. FernandoBassoSep 22, 2010
  10. Andrew KellerSep 22, 2010
  11. FernandoBassoSep 22, 2010
  12. FernandoBassoSep 22, 2010
  13. Tor ArntsenSep 22, 2010
  14. Dmitry PotapovSep 22, 2010
  15. Thomas HochsteinSep 22, 2010
  16. Dmitry PotapovSep 22, 2010
  17. Dmitry PotapovSep 22, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.