3

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...

1
  • It's generally not recommended to store passwords in scripts. Commented Jul 9, 2012 at 12:46

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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 =)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.