tags:

views:

35

answers:

1

I want to set my password on push only not for pull.

Is there any way to do that?

+2  A: 

If you have two different ways of interacting with the remote repository, one of which requires a password (for pushing) and one of which doesn't (for pulling) you can do this:

[remote "origin"]
    # the lightweight git protocol doesn't use passwords
    # this will be used for fetch/pull
    url = "git://git.foobar.org/foobar"

    # this line is there by default; don't mess with it
    fetch = +refs/heads/*:refs/remotes/origin/*
    # SO, that's not a C comment... */

    # ssh requires password/key
    # this will be used for pushes
    pushurl = ssh://[email protected]/foobar

Substitute the correct URLs in there, and you should be good to go.

Jefromi
Which file i have to modified to set up this. I am using git GUI for push data and git bash for pull data. I am working on windows.
krunal shah
This goes in the gitconfig for this particular repo. You could do it by cd-ing to the repo, and running `git config remote.origin.pushurl 'ssh://[email protected]/foobar'`.
Jefromi