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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:25:00+00:00 2026-06-09T12:25:00+00:00

I´m new to git and I´m having this weird thing. I checkout to a

  • 0

I´m new to git and I´m having this weird thing. I checkout to a branch, do some changes, then I checkout to master and the changes I made in the other branch are there. I´m not sure if I misunderstand the concept or I´m doing something wrong. The git version is 1.7.11-preview20120710 from msysgit.

This is a sequence of commands I made, I remove the file text.txt in mybranch, then in master the file is removed too.

db@DB-PC /f/Projects/Controls (master) 
$ ls
AcNumericSingleToolStripTextBox.vb  NumericSingleTextBox.vb

db@DB-PC /f/Projects/Controls (master)
$ touch text.txt

db@DB-PC /f/Projects/Controls (master)
$ git checkout -b mybranch
Switched to a new branch 'mybranch'

db@DB-PC /f/Projects/Controls (mybranch)
$ ls
AcNumericSingleToolStripTextBox.vb  NumericSingleTextBox.vb  text.txt

db@DB-PC /f/Projects/Controls (mybranch)
$ rm text.txt

db@DB-PC /f/Projects/Controls (mybranch)
$ ls
AcNumericSingleToolStripTextBox.vb  NumericSingleTextBox.vb

db@DB-PC /f/Projects/Controls (mybranch)
$ git checkout master
D       Controls/text.txt
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 5 commits.

db@DB-PC /f/Projects/Controls (master)
$ ls
AcNumericSingleToolStripTextBox.vb  NumericSingleTextBox.vb

Text.txt is not in master anymore.

Edit for depot

I had the problem before creating that example text.txt. Now I renamed AcNumericSingleToolStripTextBox.vb to NumericSingleToolStripTextBox.vb in mybranch, and I can see the change in master:

db@DB-PC /f/Projects/Controls (master)
$ ls
AcNumericSingleToolStripTextBox.vb  NumericSingleTextBox.vb

db@DB-PC /f/Projects/Controls (master)
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 7 commits.
#
nothing to commit (working directory clean)

db@DB-PC /f/Projects/Controls (master)
$ git checkout -b mybranch
Switched to a new branch 'mybranch'

db@DB-PC /f/Projects/Controls (mybranch)
$ ls
AcNumericSingleToolStripTextBox.vb  NumericSingleTextBox.vb

db@DB-PC /f/Projects/Controls (mybranch)
$ mv AcNumericSingleToolStripTextBox.vb NumericSingleToolStripTextBox.vb

db@DB-PC /f/Projects/Controls (mybranch)
$ ls
NumericSingleTextBox.vb  NumericSingleToolStripTextBox.vb

db@DB-PC /f/Projects/Controls (mybranch)
$ git checkout master
D       Controls/AcNumericSingleToolStripTextBox.vb
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 7 commits.

db@DB-PC /f/Projects/Controls (master)
$ ls
NumericSingleTextBox.vb  NumericSingleToolStripTextBox.vb 
  • 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-09T12:25:02+00:00Added an answer on June 9, 2026 at 12:25 pm

    In your example, Git was never told to track text.txt.

    Before you checkout of master, you must tell Git to track it.

    $ git add text.txt
    

    Once text.txt is staged, commit the addition to the branch.

    $ git commit -m 'Added text.txt'
    

    While on mybranch, tell Git that you want to remove text.txt. Associate that change with mybranch by committing the change.

    $ git rm text.txt
    $ git commit -m 'Removed text.txt'
    

    After checking out to the master branch, Git will restore its state and text.txt.

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

Sidebar

Related Questions

I 'm relatively new to git and and having some problems early on. I've
I am new to git and if this ques is simple then please bear
I'm having problems getting hudson to checkout my git repo and merge into master.
I'm somewhat new to Git. So I've got the origin/master and origin/upbranch on my
I am new to Git and I seem to have one branch too many
Having a weird issue. I'm new to Macs and have a windows VM that
I'm quite new to Git: I come from SVN and there I found really
We're starting new web site development with Umbraco, and having some difficulties with optimal
I'm new to git so forgive me if this is a dumb question. I
I'm relatively new to git, having used Subversion primarily in the past. I recently

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.