DEV Community

Uditha Ishan
Uditha Ishan

Posted on

Git single command executor

git add .
git commit -m "message"
git push origin <branch>
Enter fullscreen mode Exit fullscreen mode

Are you tired with writing this kind of multiple git commands?
Do you prefer using a single command to do this?
I have created an npm CLI package to do the job for you.

git-quick

What is this? πŸ‘€

This npm CLI can execute multiple git commands only using a single command line.
Let's get the above git command example.
now that three-line execution you can execute in a single line using the git-quick.

giq p "commit message" <branch>
Enter fullscreen mode Exit fullscreen mode

Easy and quick

not only this. but there are more πŸ˜‰
You can see all of them in the documentation.

I'm inviting you all to try this. If you like, don't forget to give feedback ❀ and a Star⭐ on the github repo

If you found any issues, open a New Issue in my git repo. ✨
Any contribution is welcome.πŸ˜‰πŸ‘€

git-quick on NPM registry
git-quick on Github

Oldest comments (6)

Collapse
 
duncte123 profile image
Duncan

Why did you choose node for this instead of sh or bash?

Collapse
 
udithaishan profile image
Uditha Ishan

I got curious about publishing an npm package. that's why I used node.

Collapse
 
tominoff profile image
Tominov Sergey • Edited

giq p is not consistent. If you pass 3 args - it will add all files and push with message, but if less - it will just push.
Also, as Duncan says - why we need install node for this kind of things? I believe shell is better for this kind of scripts.

I suggest you take attention on shell aliases.
For example - alias gad="git add", alias gcm="git commit -m" and so on.
To create multicommand tasks you can simply create shell function:

__git-add-commit-push() {
  if [ $ARGC -gt 1 ]; then
    git add . && git commit -m "${1}" && git push origin ${2}
  else
    echo "Wrong usage, please pass <message> <branch>"
    return 1
  fi
}

alias gacp="__git-add-commit-push" 
Enter fullscreen mode Exit fullscreen mode
Collapse
 
udithaishan profile image
Uditha Ishan

I got curious about publishing an npm package. So that's why I used node. I'm happy to look at your recommendations.

Collapse
 
cabbage profile image
cab

So, first of all. I don't like shortcuts for just adding all changes & pushing them immedietly. IMHO - unless you review every change beforehand - this is bad practise. git add --interactive is a great builtin tool to review your changes before committing them.

Then most of the quick-command cand be done with git aliases which do note require a whole node process.
Here is an example from my global git-config:

[alias]
  amend = commit --amend
  co = checkout
  br = branch
  ci = commit
  cim = commit -m
  st = status
  sti = status --ignored
  fp = fetch --all --prune
  ai = add --interactive
  cp = cherry-pick
  hist = log --pretty=format:'%Cred%h %Creset%ad %Cgreen(%ar) %Cred|%Creset%s%Cgreen%d %Creset[%Cblue%an%Creset]' --graph --date=short
  type = cat-file -t
  dump = cat-file -p
  staged = diff --cached
  unstage = reset HEAD --
  undo = reset HEAD~
  last = log -1 HEAD
  new-push = !git push -u origin $(git rev-parse --abbrev-ref HEAD)

Enter fullscreen mode Exit fullscreen mode

Also, for someone who's apparently into optimising his git-workflow, you should try to make more meaningful commit-messages. Looking over the commit-log of your repo, all I see is "updated". Please for the sake of the people who want to work with you on the same projects read this short article about git commit-messages

Collapse
 
udithaishan profile image
Uditha Ishan

Thank you for your feedback. Next time I follow good practices.