Username and password in command for git push

Jake picture Jake · Apr 21, 2015 · Viewed 204.9k times · Source

It's possible to clone down a git repository, specifying username and password in the command. Example:

git clone https://username:[email protected]/file.git

Is it is possible to also specify the username and password when pushing? So that, for example, running git push origin --all will then output asking for a password. I want this in one command.

(I am aware of the ability to set up keys and other solutions, but I want to know if there is a way to just keep using username and password with one command.) I am running Git Bash on Windows 8.1.

Answer

number5 picture number5 · Apr 21, 2015

Yes, you can do

git push https://username:[email protected]/file.git --all

in this case https://username:[email protected]/file.git replace the origin in git push origin --all

To see more options for git push, try git help push