├── .gitignore ├── GitAutoPush └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | '~*' 2 | -------------------------------------------------------------------------------- /GitAutoPush: -------------------------------------------------------------------------------- 1 | :loop 2 | 3 | :: Navigate to the directory you wish to push to GitHub 4 | ::Change as needed. Eg. C:\Users\rich\Desktop\Writings 5 | cd 6 | 7 | ::Initialize GitHub 8 | git init 9 | 10 | ::Pull any external changes (maybe you deleted a file from your repo?) 11 | git pull 12 | 13 | ::Add all files in the directory 14 | git add --all 15 | 16 | ::Commit all changes with the message "auto push". 17 | ::Change as needed. 18 | git commit -m "auto push" 19 | 20 | ::Push all changes to GitHub 21 | git push 22 | 23 | ::Alert user to script completion and relaunch. 24 | echo Complete. Relaunching... 25 | 26 | ::Wait 300 seconds until going to the start of the loop. 27 | ::Change as needed. 28 | TIMEOUT 300 29 | 30 | ::Restart from the top. 31 | goto loop 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub-auto-push-for-Windows 2 | 3 | When writing documents (such as your thesis or a paper), it's a nice idea to have different versions of that document. With versioning, you can look up past versions and copy out whatever has been lost in newer versions. 4 | 5 | No matter what files you want to back up and version, just pop them into a folder somewhere and let this script automatically push them to GitHub. 6 | 7 | Let's say you have a file called `Thesis.docx` (a Word document) and a folder on your desktop called `Writings`. 8 | 9 | - Place your `Thesis.docx` file into your `Writings` folder (and anything else you want uploaded to GitHub). 10 | 11 | - Next, go to GitHub and create your repository (lets call it Writings, too) and clone your new repository to your desktop (To the Writings folder). 12 | 13 | - Make sure that your GitHub repository is set to SSH: 14 | 15 | ![SSH settings](http://s32.postimg.org/7z323cklh/ssh_pic.png) 16 | 17 | GitHub requires a username and password and this can be really annoying if you have to type it in every time you push. 18 | You can cache your username and password by running the following from your command prompt: 19 | 20 | ``` 21 | $ git config credential.helper store 22 | $ git push https://github.com//.git 23 | Username for 'https://github.com': 24 | Password for 'https://USERNAME@github.com': 25 | ``` 26 | 27 | Where `` is the name your your repo (Writings in this example), and `` and `` are well... your username and password for GitHub. Source: http://stackoverflow.com/questions/8588768/git-push-username-password-how-to-avoid 28 | 29 | - Open the GitAutoPush.batch file and edit `cd ` by replacing `` with the path to your directory (Writings). 30 | Eg: `C:\Users\Rich\Desktop\Writings` 31 | 32 | - Now that you are all set up, run the GitAutoPush.batch file. 33 | 34 | It will by default, `push` every 300 seconds (5 minutes). It will `pull` any changes made to your repository, too. 35 | It will push any files in your `Writings` directory, so make sure that you know what is being pushed. 36 | 37 | Change as required. 38 | --------------------------------------------------------------------------------