Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push/pull origin [branch] shortcut?

Tags:

git

commit

push

I've been using git in the console for the last couple of months and I feel like there's a little too much typing.

Here's my flow (assuming I'm on foo branch):

[ ... working ... ]
git add .
git commit -m "Commit message"
git pull origin foo
git push origin foo

I know it's one of first world problems but is there a way of cutting the typing here? Can I just use git pull and git push for example? What's the difference between git push, git push origin foo?

like image 411
Wordpressor Avatar asked Dec 03 '25 09:12

Wordpressor


2 Answers

For git push, you can configure to automatically push to remote branch with the same name as local using configuration.

git config push.default current

https://git-scm.com/docs/git-config#git-config-pushdefault

For git pull, you will need to make local branch tracking branch to remote branch.

Refer to https://stackoverflow.com/a/19279975/1433665

like image 79
TheKojuEffect Avatar answered Dec 04 '25 21:12

TheKojuEffect


git commit -am 'subject: research the commands, Luke!'
git push

is equivalent unless you've added new files yourself, so you need to tell Git to hunt them down and track them with git add ., or git push sees new history on the remote branch you're tracking that you didn't know about already, so you need to pull first.

like image 35
jthill Avatar answered Dec 04 '25 22:12

jthill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!