1

I downloaded a project in the form of a .zip file from a friend. I imported it into Eclipse and it's all fine and the build goes smoothly.

Now I want to put it into a remote GIT repository.

However, there are lots of library files, IDE generated files, and misc. binaries in my workspace.

How would I do this? I don't want to put everything from my workspace into GIT (for the sake of saving space). How do I even know what should be subject to source/revision control (even some of the editable files will not ever be changed) ?

What my end goal is for someone else to check out the project from GIT, import it into their IDE, and start working on it. If I don't put the binaries into GIT, their build will fail obviously.

2Parrots
  • 33
  • 3
  • What do mean in your last sentence, about the binaries being necessary for their build? Are these library dependencies that you speak of? – pattivacek Mar 11 '14 at 13:35

2 Answers2

0

In case you weren't already aware, you will probably want to make great use of the .gitignore feature (see here). You will want to list everything that shouldn't be checked in or shared in that file, most likely using wildcards for specific folders or filetypes that will never be checked in.

As far as determining what to ignore, that can be a bit tricky, but here's a start. If you can do some sort of make clean type of command, something to clear any unnecessary/generated/compiled files, that will give you a good idea of what the minimum set of files might be.

However, the specific files that you will want to ignore depend on which language you are using, which compiler, possibly which IDE (if applicable), and if you have added any documentation or data files for testing purposes that are not meant to be shared.

Generally, if your code is meant to be used with a variety of compilers, you probably want to ignore anything that is generated/compiled by a specific compiler. Same goes for using multiple IDEs. Usually, you will want to ignore all binary files, but if you want to have a set of 'canonical' builds or library dependencies, you are allowed to check those in. However, you may want to put them in a special directory, so you can still ignore intermediate builds if you want.

A couple discussions of checking binaries into git repos (and why it is usually considered less than good): Managing large binary files with git and http://robinwinslow.co.uk/2013/06/11/dont-ever-commit-binary-files-to-git/

Community
  • 1
  • 1
pattivacek
  • 5,617
  • 5
  • 48
  • 62
0

Place a .gitignore file in the root of the repository. In this file you would indicate patterns of files not to be checked in. (For example, build output or user-specific files.)

For example, in a Visual Studio project the act of building would create bin and obj folders, so this file might simply contain the text:

bin
obj

Wildcards also work, so to ignore .user files I might also include:

bin
obj
*.user

There are probably examples floating around of more general-purpose .gitignore files which cover 99% of cases. For example, a .NET open-source project I work on has this:

# 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

I imagine browsing a few popular GitHub repositories will yield other such examples. GitHub, of course, even has a repository of examples. As you can see though, you can target a lot of specific things and tailor the .gitignore rules to your repository/project. You're correct in that dependency libraries need to be included whereas build output needs to not be included. As long as they're separately identifiable you're good to go.

For example, one might put dependency libraries in a folder called lib and explicitly add that to the git repository. Indeed, once added a file will not be ignored even if it's in the .gitignore pattern rules. Those rules tell git which files not to add, but already-added files continue to be tracked.

David
  • 208,112
  • 36
  • 198
  • 279