Skip to content

syedjafer/git-push-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gitAutomatePush

To track your files and push automatically to your github repo .

Ingredients:

  1. Repo name
  2. User name
  3. Filepath to track (the file)
  4. Default Commit Message
  5. Mainly , Oauth Token . you can get it from here

PROCEDURE FOR GETTING TOKEN >

Navigate to https://github.com/settings/tokens . Then click on generateNewToken . You will be prompted by ,

alt text

Then click on repo Radio button for permission to access the repo .

Then you will get a token . Make sure you copy it some where . bcoz its the last time you are seeing it .

alt text

Hurray !! You got the Token .

Cooking Procedure .

  1. Open gitAutoPush.py file .
  2. Edit all the necessary details such as ,
        self.filename = 'tes_file.txt' # Your file name 
        self.git_repo_name = 'gitAutomatePush' #Do not include .git extension
        self.git_user_name = 'syedjafer' # username 
        self.git_oauth_token = '<Your Auth Token>' # Your Auth Token
        self.git_commit_msg = 'Update the file' # Your Commit Message
  1. This snippet will track the file for changes using the timestamp . If it encounters with a change in timestamp (Means there is a change in the content of the file and its ready to be pushed ) . It will add the file in the git and commir it with the default commit message .

  2. Problem of providing the username and password (here we used oauth token) is been smashed with the inline specification in

os.system("git push https://%s:%s@github.com/%s/%s.git"%(	self.git_user_name,self.git_oauth_token,self.git_user_name,self.git_repo_name))

Time to Serve

There are two ways of running this program .

  1. You can put it in the cronjob , (so that it will be triggered for every fiveminutes or your time specification )

  2. Run the program infinite times. 😛

About

Snippet to automatically trace the file and push the changes to git .

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages