We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36561
    • 38 Posts
    I would like to discuss best practices on git workflows with MODX Cloud.
    I'm pretty new to git, so my ideas could, of course, be totally naive or wrong.

    My current idea is this:

    • Have a Dev Cloud which serves as a MODX base template.
    • A git repo for static elements, CSS, Javascripts.
      I store a copy of that repo locally, on bitbucket or gitHub and on the Dev Cloud.
    • Now, I'd like to work on my stuff locally, commit and push those changes up my remote repository (bitbucket/gitHub).
    • Lastly, I want to push everything to the MODX Dev Cloud.
      [edit] this does not yet work. But I can fetch from the Cloud over HTTPS

    Does that sound sane or would you do it differently? [ed. note: saschame last edited this post 12 years ago.]
      • 36561
      • 38 Posts
      Ok, I'm in trouble with my last point above.

      I don't want to store a git repo in the web-accessible part of my Cloud. So I cloned a repo to ../home/repos/my_repo.

      Unfortunately it does not work to create a symlink from that repo to the web-accessible ../www/
      (Actually, I can create a symbolic link. But the webserver doesn't want to serve those files.)

      Any ideas?
        • 36561
        • 38 Posts
        And here's my solution to my own thread:

        The short:
        You can create a git repository in the main directory on your cloud.
        There's a global rule on Cloud, that protects .git directories from web access.

        To add a remote tracking branch and push/pull over https:
        git remote add origin https://username:[email protected]/path_and/name-of-repo.git



        The long:
        I'm assuming you want to track CSS/SASS, JavaScript and some static elements with git.
        I personally store my static elements in /core/components/static/.

        I store my git repos on bitbucket.org.
        Why? Because you get free private repos for a team of up to five members with unlimited storage. That's a great deal.


        1. Create a new MODX Cloud instance
        2. SSH into that Cloud
        3. create a .gitignore file, to filter out untracked files (* ex. see below)
        4. in the web root run:
        git init


        5. change your config by running:
        git config --local user.name "Your Name"
        git config --local user.email "[email protected]"


        6. set your remote tracking branch:
        git remote add origin https://username:[email protected]/path_and/name-of-repo.git

        (This example is for bitbucket. You need to create the repo on bitbucket first)

        7. Now you can happily push/pull from that cloud
        git push origin master



        Also you could create a local copy of your MODX install and clone your repository to work locally.

        The thing to remember is, that the database is not updated, so for new static elements, you need to either

        But for JavaScript, CSS or other files, that don't live in the database, it's a treat!



        * My .gitignore template looks like this
        # Mac OS X specific
        .DS_Store
        
        # ignore everything in this directory
        /*
        
        # but not these
        !.gitignore
        !assets/
        !core/
        !_SASS/
        !_JS/
        
        # ignore assets exept css/, js/
        assets/*
        !assets/css/
        !assets/js/
        
        # ignore everything in core/ exept static/
        # to ignore other components add: !core/component/your_component_name
        core/*
        !core/components/
        core/components/*
        !core/components/static/

          • 39501
          • 163 Posts
          @saschame Thanks for sharing smiley
            • 34120
            • 236 Posts
            Another thanks here saschame, this looks great. I will give it a whirl.
              • 29597 ☆ A M B ☆
              • 350 Posts
              Thanks for this, I have a newbie question:

              4. in the web root run:
              git init

              How do I do this?
              I am unsure how I should SSH in MODX Cloud and run GitHub code...
                MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
                DESIGNfromWITHIN, MPThemes and Any Screen Size
                Follow me on Twitter | Read my blog | My code on GitHub
                • 34120
                • 236 Posts
                open git and enter the following, using your username and server details:

                You will then be prompted for your password.


                  • 34120
                  • 236 Posts
                  Hi does anyone know how to prevent git ssh connection from closing if idle for a while?

                  Also, is there a shortcut to avoid having to enter the server address and password each time?

                  Thanks
                    • 36561
                    • 38 Posts
                    What do you mean with «git ssh connection»?
                    I haven't had SSH to time-out on me, yet. How long until it disconnects?

                    You need to do git over https. So when you add your remote, be sure to add an https Server.
                    Then you can store the password within the remote-call like so:

                    git remote add origin https://username:[email protected]/path_and/name-of-repo.git

                    same for github. Just change the hostname.
                      • 40641 ☆ A M B ☆
                      • 56 Posts
                      Hi,

                      We're just trying to implement a git workflow ourselves, but seem to have hit some snags.

                      I've tried following your instructions as an example, however, I can't seem to PULL from the bitbucket repo. I can PUSH ok, but a PULL results in "Your system reports no Git commands at all". Odd, seeing as I *can* PUSH.

                      Ideally I would push and pull from the repo on the cloud directly, without bitbucket sitting in the middle, but that doesn't seem possible. I'd also *like* to connect to the remote DB from my local machine too, but that can't happen either. I'm going to attempt to use SSH tunneling, so that's my next job...

                      Anyway - have you actually managed to pull from your bitbucket repo? If so, how?