Search code examples
androidgitandroid-studiostartup

How to make Android Studio make automatic pull from git on start?


Is it possible to configure android studio to make automatic pull from git (github.com or gitlab.com) on startup? P.S. I understand that it's not always good idea but in 99% cases I need that.


Solution

  • Yes this is possible.

    Add a gradle task gitPull to your app build.grade file that looks like:

    task gitPull(type: Exec) {
        commandLine 'git', 'pull'
    }
    

    Navigate through android studio menus: File -> Settings -> Tools -> StartupTasks

    Here you can add gradle tasks to run on startup. Add the gitPull task you just created using the green plus sign on the right.

    After you reopen android studio, it will build / sync / index like normal, then a build screen will pop up from the bottom running git pull and showing you the command line output. This will happen automatically every time you open android studio.

    Good luck, hope it works for you as well as it does for me.