Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:54:49+00:00 2026-06-16T00:54:49+00:00

I want to understand what git looks for when merging with two different code.

  • 0

I want to understand what git looks for when merging with two different code.

When does it delete code or insert

So if I have code

Foo.java (this is my code)

class Foo {
     void hello(){}
     void bye(){}
     void gone(){}
}

Foo.java (the code being fetched and merged)

class Foo{
     void hello(){}
     void wait(){}
     void bye(){}
}

If I merge the above code, will this

  1. Does it delete gone and bye method?
  2. If there was changes were made inside hello method, does it delete my ‘hello’ and rewrites it with the fetched hello?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:54:50+00:00Added an answer on June 16, 2026 at 12:54 am

    Firstly, it won’t delete bye, it will insert wait() above it. It won’t delete gone() unless it existed in the previous revision and had been deleted in the successive revision without you having touched it in between. If you had added gone() yourself (i.e. git received no indication that this should be deleted), then gone() will be found at the bottom of the merged file. Like this:

    class Foo{
         void hello(){}
         void wait(){}
         void bye(){}
         void gone(){}
    }
    

    Secondly, it wouldn’t delete your hello, it would just put the changes made into the hello() that already exists.

    Remember, if it can’t be merged, it will throw a conflict, and you will have to merge it yourself. It doesn’t just delete/add things that don’t make sense without human input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a newbie at git and want to understand how to collaborate with a
I want to understand the role interface plays in inheritance between two classes. My
I want to understand if code snippets are what I am looking for here.
I want to understand the use of xargs man in Rampion's code : screen
I have read the git man about push command, but I still don't understand
I have some basic git questions, which i do not understand yet I hope
I want to have git repos accessable in redmine. But what about auto update
This question sounds similar to many posed here, but it's obnoxiously different. I have
I am trying to understand if I really have any case for using git/mercurial.
I'm trying to understand the relationship between two git commits that are some distance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.