44

I'd like to upload NuGet.exe to github but all exe files are not listed to my local repository.

I did upload NuGet.exe file about two weeks ago at another project repo, but now I cannot upload any exe file at all. There is no global .gitignore that I specially defined.

below code is my .gitignore file. what am I missing?

# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/

# mstest test results
TestResults

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
x64/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.log
*.vspscc
*.vssscc
.builds

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder 
[Ee]xpress

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish

# Publish Web Output
*.Publish.xml

# NuGet Packages Directory
packages

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
[Bb]in
[Oo]bj
sql
TestResults
[Tt]est[Rr]esult*
*.Cache
ClientBin
[Ss]tyle[Cc]op.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML

# Windows-specific files
Thumbs.db
desktop.ini
# Mac-specific things (thanks to Michael Aaron Safyan)
.DS_Store

-- EDIT --

same files under .nuget/ directory .config and .targets files are well treated. I can check git ls-files --others -i --exclude-standard gives NuGet.exe is ignored, but I don't know which rule makes it.

Youngjae
  • 24,352
  • 18
  • 113
  • 198

3 Answers3

80

First, you can check if a file is locally ignored ion your repo with git check-ignore:

git check-ignore -v -- yourFile

Second, you can force to add that file (bypassing any ignore rule):

git add -f yourFile
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. I did what you answered, but I would like to know which is the cause of ignorance of `.exe` file. whether it's cause of my `.gitignore` or somewhere settings in git. – Youngjae Mar 08 '14 at 09:04
  • 3
    @Youngjae that is what `git check-ignore -- yourFile.exe` is supposed to tell you. – VonC Mar 08 '14 at 09:20
  • // sorry to hold your leg. but `git check-ignore -- test.exe` gives `test.exe` simply. looks it's fine that git confirms me the file `test.exe` is ignored. but I'm still scratching my head *why* it is ignored.... – Youngjae Mar 08 '14 at 09:31
  • 7
    @Youngjae try a `git check-ignore -v -- yourExe.exe`: that should display the .gitignore file and the line within that file causing your exe to be ignored. – VonC Mar 08 '14 at 10:07
  • 8
    WOW! thanks you. `-v` is important! it gives me `C:\User\Me\Documents\gitignore_global.txt : *.exe`. Definitely what I can understand. – Youngjae Mar 08 '14 at 11:34
  • @Youngjae Excellent. It was a global `.gitignore` file, then. Well spotted. – VonC Mar 08 '14 at 11:35
  • `git add -f myfile` did not work for me. My exclusion of *.exe was also in gitignore_global.txt. `!myfile.exe` did work though. – RobG Jun 03 '15 at 23:46
  • 2
    @RobG if you were trying to add `myfile.exe` (which you succeeded to exclude from the `.gitignore`), then the command should have been `git add -f myfile.exe` – VonC Jun 04 '15 at 06:52
  • Thanks, that is what I am looking for! – Ruben Sep 29 '15 at 11:39
21

I just put !NuGet.exe at first in .gitignore file and work perfect for me

Oswaldo Alvarez
  • 4,772
  • 1
  • 22
  • 20
  • prob not needed (as of 2021) as the `gitignore_global.txt` , that gets created by the Git installer in the user's documents folder, should already have a rule to ignore `*.exe` – Thiago Silva Aug 27 '21 at 16:05
0

I used TortoiseGit in Windows using Windows UI, navigated to the folder, right-clicked and added the .exe files directly. These added files showed up in SourceTree and I committed them from there.

DragonSpit
  • 458
  • 4
  • 9