Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Mayur Pande
PLUS
Mayur Pande
Courses Plus Student 11,711 Points

Using linux to code I get a duplicate file that I have created

I have started using ubuntu to when developing. However whenever I create a file and save it, it seems to create a duplicate, for example I have created a index.php file and saved it, and then later on in the directory I can see another index.php~ alongside the index.php file. At first it didn't bother me, however as I am using git to add and commit files it seems to be a bit annoying!

Neil Anuskiewicz
Neil Anuskiewicz
11,007 Points

I don't know the answer but I'm thinking that some more detail might help people help you. Could you perhaps indicate the exact process for creating the files?

Mayur Pande
Mayur Pande
Courses Plus Student 11,711 Points

sure I simply use the command below to make a directory

mkdir build_a_simple_app

then I create my files for example my index.php

gedit index.php

then after editing files I get two files within my directory index.php and index.php~

so when I use the command

git add index.php
git commit -m "created first draft of index file"

its commits my first index.php. However when I run

git status

it gives me the result;

Untracked files 
  (use "git add <file>..." to include in what will be committed)

  index.php~

I also added and committed changes to a header.php file successfully. However I get the result;

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   inc/header.php~

1 Answer

Steven Parker
Steven Parker
231,110 Points

The file with the tilde (~) added is most likely an editor backup file. Depending on what editor you are using, you may have a setting that will make the editor remove the backup file when you close your edit session.

Of course, even then if you still have the editor running the file will be there. Be sure to exit the editor before you commit.

Mayur Pande
Mayur Pande
Courses Plus Student 11,711 Points

Thanks, am using gedit have managed to sort it out.