0

I created a new branch for new changes

git checkout -b my-new-branch

Then I made a new migration and it created a new migration file. I decided to cancel this migration so I did:

git checkout master
git status

and I have noticed that I have this new migration file in the master branch.
Why did it happen?

KazKazar
  • 121
  • 1
  • 4
  • 15
  • 2
    When you switched branches to master, your uncommitted changes (the new file) came with you. – Jon Feb 23 '16 at 13:40
  • @Jon, I find your answer very helpful. If you want add your answer as an answer to my question I will, I will vote and mark it as answer. Thanks! – KazKazar Apr 25 '16 at 11:29
  • No problem ... 2 mins – Jon Apr 25 '16 at 12:00

2 Answers2

1

The problem is because you've switched branches with uncommitted changes in your local branch. These uncommitted changes were then listed as uncommitted changes against the new branch after changing branches.

There are various options open to you to get back to a clean state depending on the situation you're in. Notably, these two are worth looking into:

git reset --hard and git clean

Jon
  • 10,678
  • 2
  • 36
  • 48
0

If you did migrated that migration file(rake db:migrate), it'll makes changes in DB which you cannot revert by checking out to master. You'll need to do migration rollback.

Migration Revert.

Else just

git stash

and go back to master, everything will be old.

Community
  • 1
  • 1
Albert Paul
  • 1,168
  • 13
  • 23