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 7414863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:11:06+00:00 2026-05-29T07:11:06+00:00

I’m starting to learn Git, reading the ProGit book from time to time. I’ve

  • 0

I’m starting to learn Git, reading the ProGit book from time to time. I’ve heard that the most powerful feature of Git is the branches, so I tried to use them. I’m hacking on the KDE project, so there is a remote server and a local copy.

So here’s my situation. I’ve coded a bugfix, but the developer responsible for that code area has gone offline without having given me a shipit, so I decided to do a different fix in the meantime. I’ve heard that branches can (and more importantly, should) be used for such situations. OK, I created a local branch

git branch bugfix

then switched to that branch

git checkout bugfix

ad then discovered that the files I had modified for the original fix were still modified. (Of course, I needed a clean directory to be able to push only the second bugfix without the first one.) Well, no problem, I thought, let’s reset if that’s what git status tells me to do. I did a reset and indeed got a clean dir. But hey, after I switched back to master

git checkout master

the modified files were no longer modified there! It was a clean dir.

Now what’s the point of branches? Can’t have two versions of a file, modified in one branch and unmodified in another one? I know about git stash, but if I do that, unstashing the changes will kill the second bugfix, because IIRC stash simply replaces one file with another one, no merging is done.

What am I doing wrong here? Why is it impossible to have the file modifed in one branch and unmodified in another?

  • 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-05-29T07:11:07+00:00Added an answer on May 29, 2026 at 7:11 am

    So, here’s what happened. You started off with a commit A from the original developer. You fixed some bugs and now you’re in B. There’s a remote branch pointing to A called origin/original-branch, and there’s a local branch pointing to B called my-changes. I don’t know what they’re actually called (use git branch -a to list them).

    ....->  A  ->  B
            ^      ^
            |      +-- my-changes
            |
            +-- origin/original-branch
    

    If you’re on B and you make a branch and start making changes, you’ll get this:

    ....->  A  ->  B  ->  C
            ^      ^      ^
            |      |      +-- bugfix
            |      |
            |      +-- my-changes
            |
            +-- origin/original-branch
    

    This is not what you want. You want this:

                   +-- my-changes
                   v
    ....->  A  ->  B
             \
               ->  C
            ^      ^
            |      +-- bugfix
            |
            +-- origin/original-branch
    

    So you have to make your new branch start where the other developer’s branch is.

    git branch bugfix origin/original-branch
    git checkout bugfix
    

    That specifies that the new branch starts from the other developer’s work. If you do this instead:

    git branch bugfix # not what you want
    

    This will cause the bugfix branch to start from wherever you are right now.

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I have a text area in my form which accepts all possible characters from

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.