git alias: Commit with arguments & push in a single command

I try to convince my coworkers to leave svn and switch to git. One problem I see coming is: It’s complicated and error-prone to have to do git commit and git push separately. So I was thinking about a git ci alias, which commits the changes and pushes it right to the server. I know, how to do that, but:

The problem is, that I want to give arguments like -m “” to git commit. So

  • How to remove all occurences of a file in index, from all git commits
  • How to see what has been checked into git, but hasn't been committed to svn via dcommit?
  • How can I uncommit the last commit in a git bare repository?
  • How to fix GITHUB commit date?
  • How do I preserve the timestamp if I split a commit via git rebase --interactive?
  • Git remove root commit
  • git ci -m "Cool change"

    should execute

    git commit -m "Cool change" && git push

    How can I do so?

  • gitosis vs gitolite?
  • Why is git erroring with 'Assertion failed' on git add .?
  • How can I save my secret keys and password securely in my version control system?
  • Git flow with github - pushing to central repo
  • How to pull specific commit code from bitbucket-git
  • move all files of current directory into subdirectory and maintain history
  • 2 Solutions collect form web for “git alias: Commit with arguments & push in a single command”

    you can “hide” git much like the “git achievement” project does. This will enable you to add scripts that look like git commands. Your basic flow should be:

    git pull --rebase

    so that history is linear like what they are used to in SVN’s update. But you must tell them that they may need to get rid of conflicts and tell them about or alias git add -A && git rebase --continue. I suggest turning on rerere and sharing those resolutions across the team with a script attached to the “alias” you’re going to make for this.

    Next, hide commit with something like this:

    git add -A
    git commit -m "message"
    git pull --rebase
    git push origin <current branch> # or set up tracking and omit the last 2 args

    These should fail gracefully on conflicts as well.

    here is the link to git achievements:

    Although I think this is not helping them in the long run, I hope this helps for now.

    For the general problem of adding arguments to one of multiple commands as an alias, the git alias works almost exactly like a normal *nix alias. The only difference it that unless the git alias starts with ! it’s assumed that git should be prepended to the command. Any arguments used in combination with an alias is prepended, to insert an argument into a loger string of commands you need some kind of shell command for parsing the arguments. See for instance this question for arguments.

    But for this question in particular. I agree with the others that this is a useful thing to do. If you’re going to push immediately after committing, I assume each user have their own public private repo (readonly for others) so that the push will “never” fail, which means it works very different from svn anyway; they must pull from different repos etc.

    If you’re instead are using one public “master repo” that everyone pulls and pushes to, this would be a even worse idea, since when the push inevitably will fail sometime, they are trained not to use “commit” then “push” but use your “ci” alias to commit and push changes; When they try to “re-commit” the changes the second part will not run because the first command does not finish with success status (but prints no changes added to commit (use "git add" and/or "git commit -a") instead).

    Git Baby is a git and github fan, let's start git clone.