git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* fast forward merge overwriting my code
@ 2021-05-22 15:48 Andre Ulrich
  2021-05-22 17:12 ` Philip Oakley
  2021-05-23  9:48 ` Johannes Sixt
  0 siblings, 2 replies; 23+ messages in thread
From: Andre Ulrich @ 2021-05-22 15:48 UTC (permalink / raw)
  To: git


Hello community,

I am new to git, and at the moment I am learning the basics. There are  
loads of good videos on the internet, but I have one specific  
question, I haven't found the answer yet:

Let's say I have a .txt file on my master branch. I used

git add .

and

git commit -m "blabla"

so everything is staged and in the history. Now I check out a new branch

git checkout -b testing

and edit the .txt file. I add some new lines at the end, but I also  
change some of the already existing lines. Then again I add and commit  
everything. Then I use

git checkout master

and

git merge testing

I would expect git to tell me "hey, wait, you have changed some of the  
first lines in the .txt file. When you merge, your code on master will  
be altered". But git just merges everything in.
Just imagine this was working code, and changing some of the first  
lines breaks everything in the following lines.
I think I have found out what is the problem: git considers this a  
fast forward merge (since there were no commits on master between the  
creation and the merging of the test branch).
But this is annoying. I want to be able to choose, what changes I want  
to keep, when I do the merge (just as in case of a 3way merge, when  
you can call a graphical merge tool to decide what lines to keep).
I know, I could git diff the latest commits hashes of both branches  
and then fix the file on testing branch accordingly. But those are two  
separate steps, and I want everything to happen in one convenient step.

Is there any possibility to do so?

Many thanks for any help in advance!
Many greetings
André Ulrich
-- 
**********************************************************************
**  Fachhochschule Koeln / Cologne University of Applied Sciences
**
**  Andre Ulrich
**  E-Mail: andre.ulrich@smail.fh-koeln.de
**********************************************************************


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-05-30 11:01 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-22 15:48 fast forward merge overwriting my code Andre Ulrich
2021-05-22 17:12 ` Philip Oakley
2021-05-23 15:01   ` Junio C Hamano
2021-05-24  9:50     ` Philip Oakley
2021-05-23  9:48 ` Johannes Sixt
2021-05-23 23:58   ` brian m. carlson
2021-05-24  6:13     ` Andre Ulrich
2021-05-24 11:13       ` Bagas Sanjaya
2021-05-24 13:16       ` Philip Oakley
2021-05-24 15:06         ` Andre Ulrich
2021-05-24 18:48           ` Philip Oakley
2021-05-25 15:14             ` Philip Oakley
2021-05-30  5:31             ` David Aguilar
2021-05-30 11:00               ` Philip Oakley
2021-05-24 17:47       ` Igor Djordjevic
2021-05-26  2:53       ` Felipe Contreras
2021-05-26 11:06         ` Philip Oakley
2021-05-26 18:33           ` Felipe Contreras
2021-05-26 20:35             ` Philip Oakley
2021-05-26 23:34               ` Felipe Contreras
2021-05-27 12:05                 ` Philip Oakley
2021-05-27 14:00                   ` Felipe Contreras
2021-05-27 15:12                     ` Philip Oakley

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).