programmatically check git for new versions if then pullHow to remove local (untracked) files from the current Git working tree?What is the difference between 'git pull' and 'git fetch'?How do I undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?Move the most recent commit(s) to a new branch with GitHow do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I revert a Git repository to a previous commit?How do I rename a local Git branch?

Does the Bracer of Flying Daggers really let a thief make 4 attacks per round?

Could a US citizen born through "birth tourism" become President?

Redirection operator, standard input and command parameters

Three phase systems - are there any single phase devices that are connected between two phases instead of between one phase and neutral?

Inscriptio Labyrinthica

What is the intuition for higher homotopy groups not vanishing?

Has anyone ever written a novel or short story composed of only dialogue?

Why are flying carpets banned while flying brooms are not?

How to declare an array without specifying its size, but with an initializer inside a class in C++?

A Real World Example for Divide and Conquer Method

Why do we need an estimator to be consistent?

A bicolour masyu

Can a crisscrossed metallic skeleton resist earthquakes for buildings?

What is the minimum wait before I may I re-enter the USA after a 90 day visit on the Visa B-2 Program?

Do I care if the housing market has gone up or down, if I'm moving from one house to another?

Are there foods that astronauts are explicitly never allowed to eat?

Could Europeans in Europe demand protection under UN Declaration on the Rights of Indigenous Peoples?

setcounter is not affecting numbering

Is this guy trying to scam me?

Why should fork() have been designed to return a file descriptor?

Does unblocking power bar outlets through short extension cords increase fire risk?

Why is there an extra "t" in Lemmatization?

What does "play in traffic" mean?

Have any lunar probes used a cold shield?



programmatically check git for new versions if then pull


How to remove local (untracked) files from the current Git working tree?What is the difference between 'git pull' and 'git fetch'?How do I undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?Move the most recent commit(s) to a new branch with GitHow do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I revert a Git repository to a previous commit?How do I rename a local Git branch?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have a digitalocean droplet running nginx to serve my html files and redirecting urls to a backend with a rest-api.



When I want to update the frontend or backend on the server, I have this tedious process of ssh'ing into it, pulling either backend or frontend, if frontend then build and restarting services. I am looking for a way to somehow automatize some steps or all of it. Is there any technologies that could help?










share|improve this question
























  • As @NewEyes suggested in their (deleted) answer, this is the sort of thing you could automate with a simple shell script and standard tools like cron (which can run a script at a specified interval). We're not going to write it for you, but if you try yourself and run into problems we can probably help out.

    – larsks
    Mar 26 at 14:13











  • stackoverflow.com/search?q=%5Bgit%5D+hook+push+to+deploy

    – phd
    Mar 26 at 14:36

















1















I have a digitalocean droplet running nginx to serve my html files and redirecting urls to a backend with a rest-api.



When I want to update the frontend or backend on the server, I have this tedious process of ssh'ing into it, pulling either backend or frontend, if frontend then build and restarting services. I am looking for a way to somehow automatize some steps or all of it. Is there any technologies that could help?










share|improve this question
























  • As @NewEyes suggested in their (deleted) answer, this is the sort of thing you could automate with a simple shell script and standard tools like cron (which can run a script at a specified interval). We're not going to write it for you, but if you try yourself and run into problems we can probably help out.

    – larsks
    Mar 26 at 14:13











  • stackoverflow.com/search?q=%5Bgit%5D+hook+push+to+deploy

    – phd
    Mar 26 at 14:36













1












1








1








I have a digitalocean droplet running nginx to serve my html files and redirecting urls to a backend with a rest-api.



When I want to update the frontend or backend on the server, I have this tedious process of ssh'ing into it, pulling either backend or frontend, if frontend then build and restarting services. I am looking for a way to somehow automatize some steps or all of it. Is there any technologies that could help?










share|improve this question
















I have a digitalocean droplet running nginx to serve my html files and redirecting urls to a backend with a rest-api.



When I want to update the frontend or backend on the server, I have this tedious process of ssh'ing into it, pulling either backend or frontend, if frontend then build and restarting services. I am looking for a way to somehow automatize some steps or all of it. Is there any technologies that could help?







git github server pull






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 12:26







Jonas Grønbek

















asked Mar 26 at 12:19









Jonas GrønbekJonas Grønbek

4271 silver badge12 bronze badges




4271 silver badge12 bronze badges












  • As @NewEyes suggested in their (deleted) answer, this is the sort of thing you could automate with a simple shell script and standard tools like cron (which can run a script at a specified interval). We're not going to write it for you, but if you try yourself and run into problems we can probably help out.

    – larsks
    Mar 26 at 14:13











  • stackoverflow.com/search?q=%5Bgit%5D+hook+push+to+deploy

    – phd
    Mar 26 at 14:36

















  • As @NewEyes suggested in their (deleted) answer, this is the sort of thing you could automate with a simple shell script and standard tools like cron (which can run a script at a specified interval). We're not going to write it for you, but if you try yourself and run into problems we can probably help out.

    – larsks
    Mar 26 at 14:13











  • stackoverflow.com/search?q=%5Bgit%5D+hook+push+to+deploy

    – phd
    Mar 26 at 14:36
















As @NewEyes suggested in their (deleted) answer, this is the sort of thing you could automate with a simple shell script and standard tools like cron (which can run a script at a specified interval). We're not going to write it for you, but if you try yourself and run into problems we can probably help out.

– larsks
Mar 26 at 14:13





As @NewEyes suggested in their (deleted) answer, this is the sort of thing you could automate with a simple shell script and standard tools like cron (which can run a script at a specified interval). We're not going to write it for you, but if you try yourself and run into problems we can probably help out.

– larsks
Mar 26 at 14:13













stackoverflow.com/search?q=%5Bgit%5D+hook+push+to+deploy

– phd
Mar 26 at 14:36





stackoverflow.com/search?q=%5Bgit%5D+hook+push+to+deploy

– phd
Mar 26 at 14:36












1 Answer
1






active

oldest

votes


















1














You can write cron script where you can check if origin branch HEAD is different form local branch HEAD:



# check remote head
git ls-remote origin refs/heads/your_branch

#check local head
git rev-parse HEAD

# if remote HEAD is different than local HEAD, then pull


This solution is for one branch only (for exapmle your_branch is master). If you want i can write for you complete script which will check if all your local branches is synchronised with remote branches.
I would like that script in python, but bash is also an option.



BTW



In my opinion auto pull is not a good solution. What if you have uncommited changes? Stash them, and after pulling apply?
What if you have unpublished commit? Are you should do just pure pull or pull with rebase?
With fetching you do not have this kind problems :)
Auto fetching is much better option in my opinion, and if you want just merge changes with your git working directory.
If you consider fetching instead pull (pull is fetch and merge) then locally you should check FETCH_HEAD, but please take into account that FETCH_HEAD is temp.



The other issue is that if your repository have submodules.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55357003%2fprogrammatically-check-git-for-new-versions-if-then-pull%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can write cron script where you can check if origin branch HEAD is different form local branch HEAD:



    # check remote head
    git ls-remote origin refs/heads/your_branch

    #check local head
    git rev-parse HEAD

    # if remote HEAD is different than local HEAD, then pull


    This solution is for one branch only (for exapmle your_branch is master). If you want i can write for you complete script which will check if all your local branches is synchronised with remote branches.
    I would like that script in python, but bash is also an option.



    BTW



    In my opinion auto pull is not a good solution. What if you have uncommited changes? Stash them, and after pulling apply?
    What if you have unpublished commit? Are you should do just pure pull or pull with rebase?
    With fetching you do not have this kind problems :)
    Auto fetching is much better option in my opinion, and if you want just merge changes with your git working directory.
    If you consider fetching instead pull (pull is fetch and merge) then locally you should check FETCH_HEAD, but please take into account that FETCH_HEAD is temp.



    The other issue is that if your repository have submodules.






    share|improve this answer





























      1














      You can write cron script where you can check if origin branch HEAD is different form local branch HEAD:



      # check remote head
      git ls-remote origin refs/heads/your_branch

      #check local head
      git rev-parse HEAD

      # if remote HEAD is different than local HEAD, then pull


      This solution is for one branch only (for exapmle your_branch is master). If you want i can write for you complete script which will check if all your local branches is synchronised with remote branches.
      I would like that script in python, but bash is also an option.



      BTW



      In my opinion auto pull is not a good solution. What if you have uncommited changes? Stash them, and after pulling apply?
      What if you have unpublished commit? Are you should do just pure pull or pull with rebase?
      With fetching you do not have this kind problems :)
      Auto fetching is much better option in my opinion, and if you want just merge changes with your git working directory.
      If you consider fetching instead pull (pull is fetch and merge) then locally you should check FETCH_HEAD, but please take into account that FETCH_HEAD is temp.



      The other issue is that if your repository have submodules.






      share|improve this answer



























        1












        1








        1







        You can write cron script where you can check if origin branch HEAD is different form local branch HEAD:



        # check remote head
        git ls-remote origin refs/heads/your_branch

        #check local head
        git rev-parse HEAD

        # if remote HEAD is different than local HEAD, then pull


        This solution is for one branch only (for exapmle your_branch is master). If you want i can write for you complete script which will check if all your local branches is synchronised with remote branches.
        I would like that script in python, but bash is also an option.



        BTW



        In my opinion auto pull is not a good solution. What if you have uncommited changes? Stash them, and after pulling apply?
        What if you have unpublished commit? Are you should do just pure pull or pull with rebase?
        With fetching you do not have this kind problems :)
        Auto fetching is much better option in my opinion, and if you want just merge changes with your git working directory.
        If you consider fetching instead pull (pull is fetch and merge) then locally you should check FETCH_HEAD, but please take into account that FETCH_HEAD is temp.



        The other issue is that if your repository have submodules.






        share|improve this answer















        You can write cron script where you can check if origin branch HEAD is different form local branch HEAD:



        # check remote head
        git ls-remote origin refs/heads/your_branch

        #check local head
        git rev-parse HEAD

        # if remote HEAD is different than local HEAD, then pull


        This solution is for one branch only (for exapmle your_branch is master). If you want i can write for you complete script which will check if all your local branches is synchronised with remote branches.
        I would like that script in python, but bash is also an option.



        BTW



        In my opinion auto pull is not a good solution. What if you have uncommited changes? Stash them, and after pulling apply?
        What if you have unpublished commit? Are you should do just pure pull or pull with rebase?
        With fetching you do not have this kind problems :)
        Auto fetching is much better option in my opinion, and if you want just merge changes with your git working directory.
        If you consider fetching instead pull (pull is fetch and merge) then locally you should check FETCH_HEAD, but please take into account that FETCH_HEAD is temp.



        The other issue is that if your repository have submodules.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 26 at 14:49

























        answered Mar 26 at 14:21









        Robert PawlakRobert Pawlak

        3342 silver badges19 bronze badges




        3342 silver badges19 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55357003%2fprogrammatically-check-git-for-new-versions-if-then-pull%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript