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

Re: Really beginner on Version Control

From
Thomas Hochstein <thh@inter.net>
Date
Sep 22, 2010, 07:31 UTC
Message-ID
<gcvg.1009220931.2922@thorondor.akallabeth.de>
In-Reply-To
<1285114417273-5557145.post@n2.nabble.com>
FernandoBasso schrieb:
> For instance, I have 'hello' in line 2 of site.php in the master branch. I
> go to the  testing branch, edit site.php, change 'hello' for 'world' at the
> same line, commit and got back to master. I merge testing into master and I
> get no conflicts. Shouldn't it conflict ? 
No.

You have changed "hello" to world in your testing branch. When you merge your testing branch back to your master branch, git will apply all changes you made in testing to master. That's not a problem in that case, as master was not changed since testing was branched from it.

Another example:

You create a testing branch from master. Now you'll go to your testing branch, change "hello" to "world", commit, go back to your master branch and change "hello" to "all" there (and commit). Now you'll get a conflict when trying to merge your testing branch - git will try to apply the change from testing (i.e. change "hello" to "world"), but can't to that as "hello" was already changed to "all" in your master branch. git doesn't know which of this conflicting [1] changes is the right one you'll want to keep, so you have to tell it.

Merging a branch into master will make git try to apply all changes that you made in this branch to the master branch. That's easy if master didn't change since you created your testing branch from it. It's also easy if master _did_ change, but never at the same places as in testing. You'll only get a conflict if you change the same line(s) in master _and_ in testing.

Regards, -thh

[1] That's why it's called a conflict.
Previous: Dmitry PotapovNext: Dmitry Potapov
Message 15 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.