Thread: want to clean up project to post on github

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    34

    want to clean up project to post on github

    I've been working on a PHP module (i.e., written in C to extend PHP). It's been a rather torturous process but I finally have some code that seems to be working reasonably well. I want to post it on github so that people can review and contribute, but I want to avoid posting any files that should not be there or would otherwise pollute and complicate the project. I want it to be nice and clean.

    I searched around and found this sample .gitignore file on github but it barely scratches the surface of the files I've got in my directory. I'm hoping someone can tell me
    a) what should be in my .gitignore file?
    b) can I delete any of these types of files without breaking my project?

    The directory contains files with these suffixes:
    Code:
    ==extensions==
    .dsp
    .orig -- i use this to distinguish a couple of original files before I was maintainer
    .php
    .lo
    .m4
    .la
    .h
    .txt
    .in
    .awk
    .so
    .lai
    .o
    .w32
    .nice
    .guess
    .status
    .c
    .global
    .objects
    .sh
    .fragments
    .deps
    .sub
    .log
    .dsw
    ==
    Should any of these be excluded in .gitignore? Or removed?

    there also appear to be a variety of makefiles:
    Code:
    ==makefiles==
    ./build/scan_makefile_in.awk
    ./Makefile
    ./Makefile.global
    ./Makefile.objects
    ./Makefile.fragments
    ==
    and finally, some files have no extension
    Code:
    ==files without any extension==
    ./build/shtool
    ./mkinstalldirs
    ./install-sh
    ./missing
    ./configure
    ./libtool
    ./Makefile
    ==
    I'm guessing I need Makefile and that most of these are required, but should they go into a git repo? Also, the file mkinstalldirs is completely empty.

    Any help/guidance would be much appreciated! I really want to get this out the door.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You most likely want to keep files with extensions .h, and .c, otherwise it seems you me that you'll have not much of a C project left

    Perhaps the .txt files contain things like readme, installation instructions, etc, so you probably don't want to leave them out of version control.

    The .orig thing was unnecessary to begin with: you should have committed before making your changes, then just trusted that the initial commit has everything was the "original". With such an approach, I would not just exclude them from version control; I would delete them.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    34
    Hi laserlight! I forget that you are also here. Hope you'll forgive me for also posting this on PHPB.

    I found a couple of .gitignore files in these PECL projects on php.net. Any comments you might have would be welcome.
    72.52.91.13 Git - pecl/languages/v8js.git/tree
    72.52.91.13 Git - pecl/networking/ssh2.git/tree

    Sorry if this question is uber primitive. I am so rusty at C it's not even funny. The good news is that my serializer module seems to be serializing. Now I just have to do the unserializing. Hoping to get some specific input after posting to github.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,664
    Does your local git repository contain for example .orig files checked in at older revisions?
    Whilst such files aren't immediately visible, they will be taking up archive space.

    The .gitignore file only works going forward. It doesn't automatically purge your repo of any files of that type at older revisions.

    If you've got no interest in letting the world know all the grubby historic details of your solo development, you might consider just making all the current files "revision 1" in a new repository (cp -r old new ; cd new ; git init). Then make your history "read only" just for your own reference.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Apr 2011
    Posts
    34
    Quote Originally Posted by Salem View Post
    Does your local git repository contain for example .orig files checked in at older revisions?
    Whilst such files aren't immediately visible, they will be taking up archive space.
    As of yet there is no git repo at all.

    Quote Originally Posted by Salem View Post
    The .gitignore file only works going forward. It doesn't automatically purge your repo of any files of that type at older revisions.
    Understood, but thank you for the clarification.

    Quote Originally Posted by Salem View Post
    If you've got no interest in letting the world know all the grubby historic details of your solo development, you might consider just making all the current files "revision 1" in a new repository (cp -r old new ; cd new ; git init). Then make your history "read only" just for your own reference.
    This is along the lines I'm thinking, although I was imagining I would create a repo on github, clone it to some local directory on my workstation, copy all my source files into the resulting directory, and then commit everything to the master branch.

    What do you mean by "make your history read only" ?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,664
    > What do you mean by "make your history read only" ?
    I mean make a separate parallel directory which is read-only containing any background info you might want to refer to later.

    The repo you share with the world is the only one you work on, after you've committed to sharing with everyone else.

    Eventually, you'll be able to get rid of the increasingly ancient and out of date information.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    956
    Quote Originally Posted by sneakyimp View Post
    This is along the lines I'm thinking, although I was imagining I would create a repo on github, clone it to some local directory on my workstation, copy all my source files into the resulting directory, and then commit everything to the master branch.
    The beauty of Git is that you can create a repository on your computer first and then share it later. I usually work on code in a local repository first, create an empty repository on Github, and then push my local repository to that new repository.

  8. #8
    Registered User
    Join Date
    Apr 2011
    Posts
    34
    Quote Originally Posted by christop View Post
    The beauty of Git is that you can create a repository on your computer first and then share it later. I usually work on code in a local repository first, create an empty repository on Github, and then push my local repository to that new repository.
    I like this idea a lot, but have not yet caught the hang of remotes and such. Also, I sometimes want to work privately and avoid posting my embarrassing changes to something as public as github.

  9. #9
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by sneakyimp View Post
    I like this idea a lot, but have not yet caught the hang of remotes and such.
    OK. I don't want to pile on here but you might not need a remote. Especially if you only have one project at a time. When you clone a repository from github, "origin" remotes are set up for you.
    Last edited by whiteflags; 09-30-2015 at 03:20 PM.

  10. #10
    Registered User
    Join Date
    Apr 2011
    Posts
    34
    Quote Originally Posted by whiteflags View Post
    OK. I don't want to pile on here but you might not need a remote. Especially if you only have one project at a time. When you clone a repository from github, "origin" remotes are set up for you.
    Yes but if you already have a local repo that was created before the repo on github, you have to figure out how to take your local repo's remote and set it to the git hub repo -- or you have to qualify your push statements with where you want to push, etc.

  11. #11
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    956
    Quote Originally Posted by sneakyimp View Post
    I like this idea a lot, but have not yet caught the hang of remotes and such.
    There's a bit to learn with Git, but it's not really that difficult. In fact, Github even gives you the right commands to add your Github repository as a remote in your local repository.

    Also, I sometimes want to work privately and avoid posting my embarrassing changes to something as public as github.
    I know what you mean--I don't like to publish my "dirty laundry" either, so to speak. When you are ready to publish your code, you can create an "orphan" branch that does not contain any commit history. Or you can edit the history to "squash" out only the embarrassing commits, but that's slightly more involved than creating an "orphan" branch.

  12. #12
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    The files you want to exclude can be identified by doing a "clean", then committing everything that remains. Then do a build, and run "git status". It will show a bunch of "untracked files." Those are the files/patterns that you should add to your .gitignore file.

    This won't catch everything. A lot of environments store things like personal settings inside the tree. You'll just have to weed those out one by one.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 08-02-2013, 06:45 PM
  2. How do I compare cloned github projects?
    By KenJackson in forum Tech Board
    Replies: 2
    Last Post: 06-09-2013, 10:39 AM
  3. Replies: 7
    Last Post: 10-20-2010, 11:25 PM
  4. Help me clean this up.
    By uriel2013 in forum C++ Programming
    Replies: 5
    Last Post: 05-03-2003, 10:50 PM