On Sep 3, 2012, at 11:34 , Konstantin Khomoutov wrote:
> On Mon, 3 Sep 2012 02:29:12 -0700 (PDT)
> mem <talofo.l...@gmail.com> wrote:
>> While checkout to master branch, I got:
>> Error: The following untracked working tree files would be
>> overwritten by checkout:
>> dev is ignoring those files. master isn't, because no .gitignore file
>> is present there. Perhaps, when I was setting branches, I forgot it
>> They should both ignore those files.
>> Plus, when I push this to remote repos, those changes should be
>> propagated for those remote repos as well. (I'm using a bare repo).
> Since .gitignore is a part of the repository snapshot forming a commit,
> it will be "propagated" when people check out that state.
>> My question is:
>> *How can we add that .gitignore file to the master, so that this
>> doesn't happen again ?*
> I'm a bit confused because the straightforward answer seems to be a
> bit too easy to be serious: "just check out the `master' branch,
> add .gitignore file and commit" or, alternatively, cherry-pick the
> necessary commit(s) which dealt with .gitignore from your "dev" branch.
Issue is solved. But thanks for your reply.
I was enable to checkout the master branch, unless I force it:
git checkout --force master
Anyway, for the record: here's the steps I've done with help from others:
1) I have cloned the project to somewhere else.
2) I've checkout master on that clone.
3) Placed the gitignore into the master as it should have been there from the
git show dev:.gitignore > .gitignore
3) I've removed the files from the tree by doing git rm "all files that where
on gitignore one by one"
4) I've added the .gitignore file to the repo.
5) commit it
6) switch back to the original repo and did:
7) git fetch /path/to/fix-project master:master
8) git checkout master, and I got:
Switched to branch 'master'
Your branch is ahead of 'hub/master' by 1 commit.
this is my remote master branch.
9) Pushed to remote master.
10) checkout dev again
Thanks again for your reply.
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to
For more options, visit this group at