Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How can I commit and push the commit under another user's name? #1257

Answered by Byron
scriptxyz asked this question in Q&A
Discussion options

Hi,

I'm trying to write a script and running the script on a linux box. I need to use an user account to connect to the git repo

Currently I'm using below command to clone the repo:

remote_url = "ssh://UserA@git.corp.com:/package"
git_env = {"GIT_SSH_COMMAND":"ssh -i key -o StricktHostKeyChecking=no""}
Repo.clond_from(remote_url, "/tmp/repo",env=git_env}

The clone command works fine .But I need to commit changes and push the changes under this user account.
I didn't find any document about how to set env when commit and push the change.

Any suggestion?

You must be logged in to vote

In the documentation about remotes you will find this:

ssh_cmd = 'ssh -i id_deployment_key'
with repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
 repo.remotes.origin.fetch()

which applies to pushes as well.

Replies: 1 comment

Comment options

In the documentation about remotes you will find this:

ssh_cmd = 'ssh -i id_deployment_key'
with repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
 repo.remotes.origin.fetch()

which applies to pushes as well.

You must be logged in to vote
0 replies
Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /