Sherlock
Sherlock

Reputation: 7597

git merge doesn't update .gitignore

I have a problem with updating the .gitignore file across multiple branches. I have no clue what I'm doing wrong.

The steps I took are the following:

I went back to master - where my 2 lines are still present in .gitignore -, tried to commit again ("No changes detected"), tried to push again ("Nothing to push"), checked out develop again and merged master again ("Already up to date").

So now my .gitignore file differs on my 2 branches and there seems to be no way to get the change from master into develop.

(Of course I could manually add the same 2 lines I added in master, in develop, but that doesn't solve the nature of the problem.)

Upvotes: 1

Views: 523

Answers (1)

Robert Bain
Robert Bain

Reputation: 9586

You need to do a git add before your commit. Let me elaborate, you say you do the following:

  1. git checkout master
  2. add 2 lines to the pre-existing file .gitignore
  3. git commit etc.

I would have expected:

  1. git checkout master
  2. add 2 lines to the pre-existing file .gitignore
  3. git add .gitignore
  4. git commit

Upvotes: 1

Related Questions