github - Git short cut for adding, commiting and pushing to a remote repo -
is possible run following commands @ once:
1. git add . 2. git commit -m "message" 3. git push orgin/master
i know the first 2 can sort of joined this:
git commit -am "message"
i want push remote after committing locally without having go through these steps.
imho possible, if
- you programmer contributing
- you using 1 local repository push changes remote
and takes away flexibility , power git gives you.
if so,
you can use 'alias'
so can job.
$ gitfunction() { > git add . > git commit -m "$1" > git push origin } $ alias git-all="gitfunction" $ git-all 'commit message' //will you.
or
add .git/config file.
[alias] sync = "!sync() { git add . && git commit -m \"$1\" && git push $2; }; sync"
later can use
$git sync 'commit message' remote_repo
but shouldn't doing this!!
why?
though off topic, love quote principle of sufficient reason
nothing without reason or cause
git, when designed linus had these steps separate because of sufficient reason. if abusing won't full potential out of it. have best practices followed.
from intend achieve, view git as, tool upload source-code changes remote server, way wrong , takes away goodness git gives you.
why git add
shouldn't automated?
git add helps add untracked files/ add modified files staging area. later go commit. doing git add .
add staging area. times have something, don't want commit or there in specific commit.
why git commit -m "message"
shouldn't automated?
a commit message explains changes happened after last commit. commit message helps other programmers collaborating understand changes have done. shouldn't writing senselessness in commit message
why git push
shouldn't automated?
even present logic, step should fail if not programmer contributing project. there changes in remote, should pulling. , in best case automatic merge happen , can directly git push next step. in case of conflict, need resolve conflicts, commit changes, merge , push (which way, not easy automate if possible).
also won't pushing same remote , won't pushing same branch time. these things variable , needs developers decision.
so, try understanding git , give second thought on these.
read pro git free , best book on git.
Comments
Post a Comment