iRonin
iRonin

Reputation: 470

Git config: private remote url

How to override [remote "origin"] url set in .git/config?
Sometimes I need to use an https protocol with my username and password as part of the url and I wouldn't like to commit such information. One option is to ignore .git/config.
Is there a way to:
a) override it (from global .gitconfig?), or
b) have a local .git/config but without worrying it could be commited, or
d) have an alias to git push https://privateurl master, or
c) have it working in some other way?

Upvotes: 1

Views: 1831

Answers (2)

raveturned
raveturned

Reputation: 2677

I think you are misunderstanding how Git works. The files in your .git directory store the information Git needs to operate. This includes repository information (commits, objects, pointers etc) as well as meta information (the local index, local preferences and so on). Files inside the .git directory aren't stored in the repository, as they essentially are the repository. Meta information (such as settings in .git/config) will not be pushed to remote repositories.

See this entry in the Git Community Book for a (brief) overview of the .git directory, and this question for further discussion.

Upvotes: 1

lars
lars

Reputation: 2015

You can add insteadOf in your $HOME/.gitconfig

Eg.

[url "https://git.host.com"]
      insteadOf = "git://git.host.com"

or

[url "ssh://[email protected]"]
    insteadOf = "git://git.host.com"

And this will add your username for ssh.

[url "ssh://[email protected]"]
    insteadOf = "ssh://git.host.com"

Upvotes: 3

Related Questions