none
Git deployment and get my files back

    Question

  • Hello guys,
    I have a question about Git deployment - is it possible to pull remote changed files?
    What I mean - you establish Git deployment and deploy Wordpress for example. Then you use it for a while and your media folder will be filled with files (pictures or other data).
    And one day you decide to clone this repo for update design, for example. But if you clone it in new place - all modified files since deploy will be missed.

    How can I get my files instead of using ftp or storing them outside of the website(which is not every time possible)?

    So is there any way to do something like remote commit?

    Thanks,
    Roman


    In Science We Trust!

    Tuesday, August 28, 2012 12:02 AM

Answers

  • Thanks for the information. This does indeed work, although it was very tricky to set up and has some caveats to its use.

    For anyone else wanting to get this working, here's how I did it:

    Disclaimer: Back up your site before doing this. I accept no responsibility for wiping your site through error or otherwise by you following this advice!

    1. Delete your existing Azure git repository by using the 'Delete Git repository' button on the right of the Azure website dashboard.
    2. Go to the 'Configure' page and under 'app settings' set 'SCM_REPOSITORY_PATH' to 'wwwroot' (without the quotes).
    3. Then click the little 'Save' button at the bottom to deploy your new config.
    4. Now go back to the 'Dashboard' tab and create a new git repository. Choose 'Local Git Repository' when asked and follow the wizard to get it set up. Your new Azure git repository will be in the same place as your wwwroot now.
    5. Push your local Git repository to your new Azure git repository as usual.
    6. Remote in to your Azure machine using KuduExec.
    7. Once in, go to the 'site/wwwroot' folder.
    8. Issue a 'git branch master' command. IMPORTANT: After every time you push your local repo to Azure, it loses the current branch on the Azure machine, so you will need to repeat this step.
    9. Make some changes to your files and commit them.
    10. Now, back on your local machine, go to your local git repository.
    11. Issue a 'git pull azure master' (or whatever name you use for your remote).
    12. Voila! 2-way syncing!
    13. Don't forget, every time you want to pull the remote repository to your local, you need to log on to the remote and use 'git branch master' to ensure it is on the right branch.

    I hope Microsoft find this information useful and can simplify it in their deployment setup pages one day. It all feels a little 'back door' currently and it would be nice if it was officially supported. Wordpress sites, for example, would find this method helps enormously.

    Thanks

    Graham

    • Proposed as answer by JGCobra Sunday, August 11, 2013 12:22 AM
    • Marked as answer by David EbboModerator Monday, August 12, 2013 2:05 PM
    Sunday, August 11, 2013 12:20 AM
  • Hi Roman,

    No, you cannot do a commit of those runtime generated file on the server. In general, that would be very hard to do, because the wwwroot folder that has your app is different from the folder that contains the repository. There is a good reason for that, as in some cases, the deployed files can be very different from the files in the repo (e.g. for .NET apps that need to be compiled).

    So the short answer is that FTP is your best bet to get at those files.

    David

    • Marked as answer by Roman Nikitin Tuesday, August 28, 2012 11:10 AM
    Tuesday, August 28, 2012 12:20 AM
    Moderator

All replies

  • Hi Roman,

    No, you cannot do a commit of those runtime generated file on the server. In general, that would be very hard to do, because the wwwroot folder that has your app is different from the folder that contains the repository. There is a good reason for that, as in some cases, the deployed files can be very different from the files in the repo (e.g. for .NET apps that need to be compiled).

    So the short answer is that FTP is your best bet to get at those files.

    David

    • Marked as answer by Roman Nikitin Tuesday, August 28, 2012 11:10 AM
    Tuesday, August 28, 2012 12:20 AM
    Moderator
  • Thanks David.

    So this is sad. It makes harder to using some apps (especially those apps, which are same in repo and after deploy, e.g. precompiled sites or php/ruby sites).

    Hope, product team will find a good solution in future :)

    For example you can move deployed files to branch 'deployed' and automatically (or manual, by request) commit all runtime changes.


    In Science We Trust!

    Tuesday, August 28, 2012 11:16 AM
  • But what's wrong with using FTP here?

    Generally, I think there is a clear separation between code and data, and data doesn't belong in your git repo. DVCS like git are particularly bad at dealing with large binary files, and they inflate the size of the repo even if you delete them later. So common git wisdom is to not store binaries in git unless you really have to.

    Tuesday, August 28, 2012 3:58 PM
    Moderator
  • "But what's wrong with using FTP here?"

    FTP is not an incremental solution, whereas a git pull is. I have no way of determining differences with FTP, so I am forced to download the whole site every time. This makes incremental round trips very time consuming.

    I think there is a strong use case for the suggestion in the original question. Wordpress sites, for example, do not need to be compiled, and it would be extremely useful to be able to pull them locally to be able to work on them, and then push them back to the server.

    My current method is:

    1) Download the whole site using FTP to my local git repository.

    2) Use git to commit the differences to my local repository.

    3) Make and test any local modifications I wish to make.

    4) Commit those modifications to my local git repository.

    5) Use 'git push azure master' to get the changes back on to Azure.

    It would be so much quicker iteration time if I could replace steps (1) and (2) with a git fetch, as it would only download files that were new or different to my local repository, and it would compress them during transit too.


    • Edited by JGCobra Saturday, August 3, 2013 7:35 PM
    Saturday, August 3, 2013 7:34 PM
  • We now support a new in-place mode which could get you closer to what you want. In that mode, the repo is directly under the wwwroot folder. So you could use KuduExec to do a server side commit, and then pull changes back down.
    Saturday, August 3, 2013 8:45 PM
    Moderator
  • Thanks for the information. This does indeed work, although it was very tricky to set up and has some caveats to its use.

    For anyone else wanting to get this working, here's how I did it:

    Disclaimer: Back up your site before doing this. I accept no responsibility for wiping your site through error or otherwise by you following this advice!

    1. Delete your existing Azure git repository by using the 'Delete Git repository' button on the right of the Azure website dashboard.
    2. Go to the 'Configure' page and under 'app settings' set 'SCM_REPOSITORY_PATH' to 'wwwroot' (without the quotes).
    3. Then click the little 'Save' button at the bottom to deploy your new config.
    4. Now go back to the 'Dashboard' tab and create a new git repository. Choose 'Local Git Repository' when asked and follow the wizard to get it set up. Your new Azure git repository will be in the same place as your wwwroot now.
    5. Push your local Git repository to your new Azure git repository as usual.
    6. Remote in to your Azure machine using KuduExec.
    7. Once in, go to the 'site/wwwroot' folder.
    8. Issue a 'git branch master' command. IMPORTANT: After every time you push your local repo to Azure, it loses the current branch on the Azure machine, so you will need to repeat this step.
    9. Make some changes to your files and commit them.
    10. Now, back on your local machine, go to your local git repository.
    11. Issue a 'git pull azure master' (or whatever name you use for your remote).
    12. Voila! 2-way syncing!
    13. Don't forget, every time you want to pull the remote repository to your local, you need to log on to the remote and use 'git branch master' to ensure it is on the right branch.

    I hope Microsoft find this information useful and can simplify it in their deployment setup pages one day. It all feels a little 'back door' currently and it would be nice if it was officially supported. Wordpress sites, for example, would find this method helps enormously.

    Thanks

    Graham

    • Proposed as answer by JGCobra Sunday, August 11, 2013 12:22 AM
    • Marked as answer by David EbboModerator Monday, August 12, 2013 2:05 PM
    Sunday, August 11, 2013 12:20 AM
  • Thanks for sharing the detailed steps! Granted, this hasn't been advertized much and you're likely one of the first to use it, so your feedback is welcome :)

    The part about it losing the current branch is quirky, and we should look into fixing that (I opened an issue to track it).

    Monday, August 12, 2013 2:28 PM
    Moderator
  • Big thanks for posting this... it was a huge help to me. I had a different situation which I don't see anyone write about: how to create a repo on an EXISTING site (everyone seems to only talk about doing it with new sites being deployed). The challenge is some files (the dynamically compiled ones, indexes from search modules, log files, etc) get included in the repo by default... not what you want.

    I documented my steps here to solve this:

    Improved Azure Web Sites 'Two-Way Sync' Deployments - More Control of your Remote Production Git Repo


    -AC [MVP SharePoint Server] http://www.andrewconnell.com

    Saturday, October 12, 2013 9:30 AM