git unexpectedly pushes untracked files
<p>I have a local git repository with .gitignore that is set to ignore some large files of the form *.lammpstrj. Running git ls-files produces the expected list of tracked files and running git ls-files -o shows that untracked files are being properly ignored. However, when pushing to the origin on github, git tries to push the large files to the remote repository causing the push to fail. Am I correctly viewing the list of untracked files or do I need to change something in git to prevent pushing ignored files? I've included the ls-files output and .gitignore file below.</p>

<p>List of cached files:</p>

<pre><code>$ git ls-files
.gitignore
BONDS/BUILD
BONDS/blen
BONDS/bond_lengths.cpp
BONDS/distributions.cpp
BONDS/functions.h
BONDS/globals.h
BONDS/read_dump.cpp
BONDS/read_xyz.cpp
BONDS/unwrap.cpp
BONDS/write_traj.cpp
COMPILE
MSD/BUILD
MSD/COMPILE
MSD/calc_msd.cpp
MSD/functions.h
MSD/globals.h
MSD/msd
MSD/msd_time.cpp
MSD/read_dump.cpp
MSD/read_xyz.cpp
MSD/unwrap.cpp
README.md
RG/BUILD
RG/chain_stats.cpp
RG/distributions.cpp
RG/functions.h
RG/globals.h
RG/read_dump.cpp
RG/read_xyz.cpp
RG/rg
RG/rg_re_com.cpp
RG/unwrap.cpp
RG/write_traj.cpp
RUN
TESTS/COMPILE
TESTS/hello.c
TESTS/sizes
TESTS/sizes.c
TESTS/test
TESTS/test.c
TESTS/test.h
TRAJ/COMPILE
TRAJ/read_dump.cpp
TRAJ/read_xyz.cpp
TRAJ/unwrap.cpp
blen
msd
rg
</code></pre>

<p>List of other (untracked) files:</p>

<pre><code>$ git ls-files . -o
BONDS/bond_lengths.o
BONDS/read_dump.o
BONDS/unwrap.o
BONDS/write_traj.o
MSD/calc_msd.o
MSD/msd_time.o
MSD/read_xyz.o
RG/chain_stats.o
RG/distributions.o
RG/read_dump.o
RG/rg_re_com.o
RG/unwrap.o
RG/write_traj.o
SAMPLE/generate.py
SAMPLE/hists.out
SAMPLE/lengths.out
SAMPLE/mol_traj.lammpstrj
SAMPLE/plot.p
SAMPLE/stats.out
SAMPLE/unwrapped_traj.lammpstrj
SAMPLE/wrapped_traj.lammpstrj
</code></pre>

<p>My .gitignore file</p>

<pre><code>*.[oa]
*.lammpstrj
SAMPLE/
</code></pre>