2

I have multiple projects on multiple domains and I have each domain project files in a folder as such.

domain1 -> web-domain1
domain2 -> web-domain2

Each domain is pushed to a version control account ( github ) account and a hosting account ( heroku ).

all of the domain folders are contained in a single folder root

root

How should I setup git so that I can push each project as I work on it. Do I need to do a git init on each web project?

Or is it possible to have only one git init so that I have only one single git repo locally, but can I configure it to do the specifics.

By specifics I mean push only project related files to the correct domain/host provider.

cade galt
  • 3,843
  • 8
  • 32
  • 48
  • 1
    possible duplicate of [GIT repository layout for server with multiple projects](http://stackoverflow.com/questions/2732020/git-repository-layout-for-server-with-multiple-projects) – Kristján Sep 17 '15 at 17:15

2 Answers2

1

Do I need to do a git init on each web project?

In short, yes.

Git, GitHub and Heroku are all geared towards handling a single project at any given moment. If your projects A, B, and C are independent of one another, each needs its own repository locally and on GitHub, and its own Heroku application to push to.

If you want to keep your source control in one big master repository, you could conceivably set up a single Git repository at root/ that you push to GitHub, and then independent Git repositories inside each application directory that you push to Heroku. This works because Git looks for the .git/ directory first in your current directory and then up through the directory's parents, so when you're in a project folder, you'd make commits to the local app for pushes to Heroku and when you're in root/, you'd make commits to push up to GitHub. You'll notice with this scheme though that every time you want to commit, you need to do it twice: once for Heroku and once for GitHub. I'd wager that quickly becomes irritating.

Kristján
  • 18,165
  • 5
  • 50
  • 62
0

You could use this shell script to manage multiple git repos.

you could run git clone https://github.com/robbenz/gitme.git to have a look. I will post it below as well.

open the script in your text editor, and enter in the file paths of your different git projects.

I saved an alias in my ~/.bash_profile called gitme to run this script and then you can run a git status or git push or git pull on all of your git projects at once. projects can be comited with either a unique or generic commit message

#!/bin/bash -e

# enter in your different git projects 
REPOS=( 
/Users/you/repo1
/Users/you/repo2
/Users/you/repo3
/Users/you/repo4
)

MOVE="Moving to next REPO... \n" 

tput setaf 2;echo "What do ya wanna do? You can say push, pull, commit, ftp push, or status"; tput sgr0

read input

if [ $input =  "commit" ]
then
    tput setaf 2;echo "Do you want a unique commit message? [y/n]";tput    sgr0
    read ans
    if [ $ans = "y" ]
    then 
        for i in "${REPOS[@]}"
        do
            cd "$i"
            tput setaf 6;pwd;tput sgr0 
            git add . -A
            read -p "Commit description: " desc  
            git commit -m "$desc"
            tput setaf 2;echo  $MOVE;tput sgr0 
            sleep 1
        done 
    else 
        for i in "${REPOS[@]}"
        do
            cd "$i"
            tput setaf 6;pwd;tput sgr0 
            git add . -A
            git commit -m "autocommit backup point"
            tput setaf 2;echo  $MOVE;tput sgr0 
            sleep 1
        done
    fi 
elif [ $input = "push" ] || [ $input = "pull" ] || [ $input = "ftp push" ] || [ $input = "status" ]
    then
        for i in "${REPOS[@]}"
do
    cd "$i"
    tput setaf 6;pwd;tput sgr0 
    git $input 
    tput setaf 2;echo  $MOVE;tput sgr0 
    sleep 1
    done 
else tput setaf 1;echo "Sorry, thats not on the list";tput sgr0 
fi
RobBenz
  • 589
  • 1
  • 7
  • 21