Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Git pull" on server after every "git push" from local machine [duplicate]

Tags:

git

My usage of git is very simple. Basically I do smth like this on my local machine:

echo 'Update' >> README.md
git add . && git commit -m 'update' && git push -u origin master

Then on server:

git pull

That's it.

And I am doing it every time I make changes on my local machine. Seems to me I can optimize this somehow, but I haven't found any git command to deal with this.

Is there a way not to print git pull every time there is a change? And maybe there is a way to automatically add && commit && push?

like image 782
Snobby Avatar asked Jun 27 '26 08:06

Snobby


2 Answers

Yes this is the normal behavior: you push on your local and pull on the server.

To automatically perform pulls you would need some kind of continueos integration tool like

http://capistranorb.com/ or https://jenkins.io/

In the special case of using github, refer to this question/answer: How do you do an automatic git pull on remote server?

Yes you can add git aliases, that performs add commit and push all together for you https://git-scm.com/book/tr/v2/Git-Basics-Git-Aliases

like image 146
Xatenev Avatar answered Jun 28 '26 22:06

Xatenev


For the second thing you can create a script.
E.g. create a file:

sudo nano /usr/local/bin/git-update

paste:

git add . && git commit -m 'update' && git push -u origin master`

then do

sudo chmod +x /usr/local/bin/git-update

and use your new command (git-update).

like image 27
Oskar Laska Avatar answered Jun 29 '26 00:06

Oskar Laska