Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to make a python script which would check for changes in my git local working folder, and automatically push them to the online repo. Currently only using git manually to do it. I want to know, what would a script require to do this without manual intervention.

The commands I'd type in my shell are:

#for checking the status, and determining if there are untracked files
git status

#if there are untracked files...add them
git add .

#add my commit message
git commit -m "7/8/2012 3:25am"

#push it to my online repo
git push origin master

#check if changes came on remote
git diff origin/master

#merge my repo with origin
git merge origin/master

When doing the git push, you'd always have to enter username/password. I know that git has a way around this which involves making ssh keys and all. But I am assuming there is some way GitPython is doing it. I mean we can pass username/password through code, or go with the former. So what are my options regarding authentication when I am using GitPython?

Edit: There are apps which actually generate the ssh keys, for e.g. github's windows application. How is the windows app doing this? My assumption is that there is surely some git api for it...

share|improve this question
    
It's generally not recommended to store passwords in scripts. –  soulseekah Jul 9 '12 at 12:46

2 Answers 2

up vote 1 down vote accepted

If you are authenticating using SSH keys, then use ssh-agent to load your key once and then you can keep using the key without having to provide the password all the time.

Alternatively, you could simply generate a key without a password, if you don’t care about your key security.

share|improve this answer

I have looked up the code to be sure, there is nothing that you can define a username/password combination for communication.

This has to be it because ssh does not give you the ability to provide password beforehand, it intentionally asks for user prompt. The only was is to use ssh keys for automation.

However, if you really want to bend your limits. There's open source app for non-interaction ssh communication without using ssh keys: http://sourceforge.net/projects/sshpass/

You compile & install this and direct a communication protocol like ssh:// to this app, it may work. However, I don't think that you should; just use keys, they're great =)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.