Help with git

Discussion in 'Mac Programming' started by itsmrjon, Sep 6, 2011.

  1. itsmrjon macrumors regular

    Joined:
    Jun 11, 2011
    Location:
    Chicago
    #1
    I was wondering if anyone knew if it is possible to create an independent git repo within an existing git repo.

    Essentially, what i have is a CFD code i wrote. It carries a folder structure such as:

    repo
    =>caseFiles =>sourceFiles =>postProcess
    ^case file folders ^multiple directories ^multiple directories

    Now the issue is, I dont want to add the caseFiles to the repo, because they change case to case, and since this is a program used by many people i wouldnt want to overwrite other peoples cases.

    So the question is, how do i elegantly track my changes in my case files without hindering others using the git repo? I tried branching and adding, but the merging screwed everything up.

    Is it possible for me to create a separate repo within the casefiles folder?

    I hope i was clear... this is overall a rather confusing situation because this is a huge shared library of cfd solvers.
     
  2. cbougher macrumors member

    Joined:
    Oct 19, 2006
    Location:
    Atlanta, GA
    #2
  3. freeki macrumors newbie

    Joined:
    Sep 7, 2011
    #3
    A few options

    If others should have some copy of caseFiles, but not yours:
    * Make caseFiles a git submodule.
    or
    * Don't track caseFiles in git. Use a script to clone / update a git repository for caseFiles. Everyone will have to run this script every time they pull in changes (or at least every time something in caseFiles changes). Use a different git repository for caseFiles in your branch.

    If it's acceptable for others to not have the default caseFiles:
    * Add caseFiles to .gitignore and and track it with a seperate git repository.
     
  4. itsmrjon, Sep 7, 2011
    Last edited: Sep 12, 2011

    itsmrjon thread starter macrumors regular

    Joined:
    Jun 11, 2011
    Location:
    Chicago
    #4
    Yes, that's along the lines of what I am looking for. Although the caseFiles are technically all the 'same', we all change them with respect to things like initial conditions, variables tracked, boundary conditions, etc. So the last thing you ever want to do is a 'git pull' and then you lose all your work.

    the caseFiles are currently added to .gitignore to prevent anyone from doing what I mentioned above. However I would like to track my personal changes, independent of others

    Would this be more effectively done using the submodule or an independent git repo? I tried to read up a bit on the submodules, but I don't really understand what I'm reading. Mind you, I'm technically not a programmer but rather an engineer/physicist, so I get lost in this stuff often.

    thanks for the response btw!
     
  5. freeki macrumors newbie

    Joined:
    Sep 7, 2011
    #5
    http://stackoverflow.com/questions/...ubmodules-over-having-a-repo-inside-another-r

    If you use a git submodule, you'll be keeping a pointer to a specific commit of the submodule in your main git repository. This makes it "easy" to check out a fresh copy of the whole thing:
    $ git clone git://git.example.com/foo.git
    $ cd foo
    $ git checkout -b mybranch origin/mybranch
    $ git submodule update --init

    You'll of course need to periodically (the order is important):
    * commit and push changes in the submodule, and
    * add and commit the submodule changes

    Which could look something like:
    $ cd foo/bar/mysubmodule
    $ git add .
    $ git commit
    $ git push origin master
    $ cd ../..
    $ git add bar/mysubmodule
    $ git commit
    $ git push origin mybranch

    Don't worry, physicists and programmers alike have trouble understanding git when first exposed to it :).
     
  6. itsmrjon thread starter macrumors regular

    Joined:
    Jun 11, 2011
    Location:
    Chicago
    #6
    Thanks for the detailed response/walkthrough!

    I'll give it a shot when I get in to work tomorrow. It looks like this may be the perfect solution (they seem to agree at stackoverflow as well!).

    But I have to warn you, us numericists/physicists/engineers/applied math guys are WAYY behind the times. Most of the lab I work in is still using F77. I'm newschool, I use F95 haha

    Although I must say, ever since I instituted the git repo, it's probably saved me atleast 3 times. Probably the most useful change we've had around here in a while. We've also begun to use git for collaborative LaTeX editing, which is pretty awesome.
     

Share This Page