wiki:faq/git-for-web-development

TranslatedPages

How can I use a git repository to manage my Drupal website?

These instructions are targeted to Linux operating systems. If you run Windows or Mac (we suggest switching to an open source OS), you can find instructions for your local machine online. The instructions for the server will be the same. For more detailed instructions on using git go here. There is another method to achieve the same effect using git remote add that might be useful.

  • ssh into your MF/PL server and navigate to your website's directory.
  • Initalize your git project with the following three commands:
    git init
    git add sites/all
    git commit -am "Initial Import"
    
  • Now we need to setup the repository's origin. We can do this on the MF/PL server, too, just in the include directory.
    cd ../include
    git clone --bare ../web REPONAME.git
    
  • We need to go back to our original .git repo and edit the config file
cd ../web/.git

so that it looks like this:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
	url = /home/members/<USERNAME>/sites/MYSITE.org/include/REPONAME.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
  • Navigate back to your web directory, where the .git directory is located, and do a push to your origin:
    git push origin master
    
  • Great! Now if you're doing development offline on your local machine, you'll need to set up the repository there, too:
    • cd into your sites directory (or wherever your have your local projects) and do:
      git clone ssh://<USERNAME>@MYSITENAME.org/home/members/MEMBERNAME/sites/MYSITENAME.org/include/REPONAME.git
      
  • Test the repository
    • From local machine in ./REPONAME/sites directory do:
      touch test-file
      git add test-file
      git commit -am "Added test-file."
      git push
      
  • From server cd into your web directory and do:
    git pull
    

Now you can use your repository for web development

Last modified 11 years ago Last modified on Feb 2, 2013, 11:08:11 PM
Note: See TracWiki for help on using the wiki.