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?
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
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With