'git pull and git push in one go
Is it possible to have git pull
and git push
in one git command?
The syntax like git pull & git push
doesn't suit me completely, since I need to provide my credentials to the server twice: on pull and on push.
So I wondering, is there any workaround for this? I believe it should be, since it's pretty common case when developer pulls remote origin before pushing local changes.
EDIT: I'm using Windows 7/x64, msysgit-utf8 1.7.9
Solution 1:[1]
First of all, you can configure _netrc file that will be used by Git, here is the related issue: Git - How to use .netrc file on Windows to save user and password Then you can configure an alias for the command:
git config alias.publish '!git pull && git push'
And just type: git publish
Solution 2:[2]
I recommend doing something just quick and dirty in this case. It may not be the most efficient way to do it, but I would just create a bash script in vim with the commands and run that considering how simple the commands are. Then you can just open that file every time you want to pull and push at the same time.
All you have to do is create the file, put in the two lines of commands you want to write, and type that filename into the command line whenever you want to execute them.
Again, not the most efficient way, but a quick fix.
Solution 3:[3]
You'd better use SSH, but if you can't use SSH, you can always use the windows credentials store to save your password so you don't need to fill it in twice:
git config --global credential.helper wincred
Source: Git documentation
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Aymen |
Solution 2 | SSEMember |
Solution 3 | Highmastdon |