Search code examples
gitcrongit-commit

How do I create a cron job that will commit all my changes in my repository every friday


I'm new to using Git and I made some research and discovered that I can run cron jobs to make my commits into my repository every certain time, my question here is.

Can I create a cron job that runs every Friday at 16:00?


Solution

  • It's not a good practice to do so.

    Let's assume that you write a script that executes

    git add . && \ 
    git commit -m ... && \
    git pull
    

    Those commands will add the content and commit them to git.

    Once you will try to push your code it will work as long as you won't have any conflicts. in case of conflicts, git will not know how to resolve the conflicts and you will start a mess in your repository.


    Example:

    Lets assume that you will run into this conflict:

    enter image description here

    how do you expect git to resolve it?


    Just to make it clear: You can auto-resolve conflicts in several ways but it's not a healthy practice so you should avoid doing so.