Search Unity

.Gitignore file stays in as a text file?

Discussion in 'Scripting' started by Hidrem, Mar 30, 2017.

  1. Hidrem

    Hidrem

    Joined:
    Mar 12, 2017
    Posts:
    22
    Hello everyone,

    I'm fairly new to the Github, Bitbucket.... I recently lost all my files because i didn't know these softwares and now i'm going on a hunt to have it working before I start over!

    Anywho, I decided to use Bitbucket (SourceTree) and for some reason when I try to implement the .gitignore file in the unity assests folder Source Tree so it can ignore the Library. The text document does not convert into a GITIGNORE file type as I see in tutorials. Moreover, Source tree doesn't recognize it...

    Here is the code:

    /[Ll]ibrary/
    /[Tt]emp/
    /[Oo]bj/
    /[Bb]uild/
    /[Bb]uilds/
    /Assets/AssetStoreTools*

    # Visual Studio 2015 cache directory
    /.vs/

    # Autogenerated VS/MD/Consulo solution and project files
    ExportedObj/
    .consulo/
    *.csproj
    *.unityproj
    *.sln
    *.suo
    *.tmp
    *.user
    *.userprefs
    *.pidb
    *.booproj
    *.svd
    *.pdb

    # Unity3D generated meta files
    *.pidb.meta

    # Unity3D Generated File On Crash Reports
    sysinfo.txt

    # Builds
    *.apk
    *.unitypackage

    Any advice?

    Thanks in advance!!
     

    Attached Files:

  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,538
    the file should be named JUST

    .gitignore

    no gitignore.gitignore

    no .gitignore.txt

    and definitely no gitignore.gitignore.txt

    If you're on windows, Windows Explorer probably complains when you try to remove the .txt, because it presumes all files should have an extension and and prefix and it sees .gitignore as a prefixless suffix.

    What I do is use a editor like Notepad++, write my .gitignore, and then Save As directly from there.
     
    Kiwasi and Kurt-Dekker like this.
  3. Hidrem

    Hidrem

    Joined:
    Mar 12, 2017
    Posts:
    22
    I did try that and it still doesn't work...
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,538
    I edited the post afterward... there's a follow up:

    If you're on windows, Windows Explorer probably complains when you try to remove the .txt, because it presumes all files should have an extension and and prefix and it sees .gitignore as a prefixless suffix.

    What I do is use a editor like Notepad++, write my .gitignore, and then Save As directly from there.

    Remember Windows Explorer by default hides extensions... you may want to disable that feature to make 100% you have it named correctly.
     
  5. Hidrem

    Hidrem

    Joined:
    Mar 12, 2017
    Posts:
    22
    Okay so I see now that it still does put it in a .gitignore.txt
    Should I just download Notepad ++ or is there a way to fix this?
     
  6. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,538
    Notepad itself should also be able to do it.
     
  7. Hidrem

    Hidrem

    Joined:
    Mar 12, 2017
    Posts:
    22
    Is there something you reccomend? It still comes back to .txt or that i need to enter a proper name for it
     
  8. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,538
    I'm on Win10 and I just did it.

    Open Notepad
    Type in what your gitignore should say
    File->Save As
    named it '.gitignore'
    Save

    File created with correct name.
     
    ShayneDsouza likes this.
  9. Hidrem

    Hidrem

    Joined:
    Mar 12, 2017
    Posts:
    22
    Nvm it actually works! The only files left are assets and project settings!! Thank you so much lordofduct! You are a life saver :D
     
  10. david_arel

    david_arel

    Joined:
    May 10, 2016
    Posts:
    7
    For folks who stumble upon this thread later on: Another way of doing this would be to directly take the .gitignore file from GitHub (https://github.com/github/gitignore/blob/main/Unity.gitignore)
    It will contain a file named "Unity.gitignore" that you can rename to ".gitignore" in Window's file explorer.
    You then need to place it at the root of your Unity project.
    Note that no matter which method you choose, if you already commited files that you now want to ignore, you need to tell Git to forget them. You can type
    git rm -r Library
    for example.

    If you need a bit more detail, I have a blog post about this: https://crafty.creatiel.ca/blog/unity-gitignore-essentials