This trouble that anyone who has a GitHub account and commits will visit. The moment you commit to GitLab on your personal server, it goes to your private repository on GitHub. When making a program that automatically recommits as a backup I've come up with a silly Python program that disguises grass, so I'll write it.
First of all, you need a computer or server to run this program. It's a good idea to put it on your personal laptop or server as a starting point. The following assumes the case of Linux.
The installation method for Python and Git is different for each OS. Please check each one.
Also, the directory structure of the one I'm about to create looks like this. (As for the README, please)
your repository/ ├ bot.py ├ bot.sh ├ bot.txt └ README.md
Would you like to appeal to someone who commits to your private repository every day?
Also, let's make it a private repository in the sense that the commit contents will not be revealed.
If you can, run
git clone <Your GitHub repos URL> in a shell on your computer to clone it to a suitable folder.
It's a big deal, and let's put this program in the folder of this repository.
#Library import import time import os import random while True: #loop #Find the current time tm = str(time.time()) #In the same folder as this program, put a txt file that records the value of the variable tm every rotation. You can write in w mode with open("bot.txt", mode = 'w') as f: f.write(tm) #This is a statement that causes a shell on your computer to execute a command. os.system('./bot.sh') #It's annoying, so I wrote all the Git commit processing in the shell script # 1-Randomly repeat every 40,000 seconds delay = random.randint(1,40000) time.sleep(delay)
I wrote it in a few minutes, so I don't really care about the result. A level where you can move. Next, write a shell script. For Windows, write in a batch file.
#! /usr/bin/bash git add . git commit -m "autocommited" git push -u origin master
Yes, this is also very simple.
bot.Since txt is written by a Python program, it can be empty.
#### **`bot.txt`** ```txt
Now let's run it in python.
If you want to run even if you close the shell #### **`python bot.py &`** ```py & If you want the server to ssh and run it even if the SSH is solved #### **`nohup python bot.py &`** ```py & Adjust the value of `` `delay``` on the Python side as you like. The shell script may not work as it is, so once #### **`chmod 755 bot.Let's secure authority by hitting sh`** ```Let's secure authority by hitting sh ## Finally -** This really works, but it's a joke program. ** ** -** We do not take any responsibility for all events caused by the growth of false grass. Do it at your own risk. ** ** ――For example, I think that some students who want to make an impression from a company think "I like this!" And execute the above program seriously. But, the contents of the code of `` `commit```, `` `push```, `` Python```, etc. in the shell script of how to create the repository of GitHub written above People who don't understand at all shouldn't do this. It's not good for me. There is more to do than doing this. definitely. I used to be like that, so with a sense of self-discipline ...