How do I do an automatic git push in IntelliJ 15?
Asked Answered
F

3

8

Currently, I work on a team that does trunk based development.

We moved the project from SVN to GIT recently, which requires me to do a push after every commit (Ctrl+K followed by Ctrl+Shift+K).

Is there a way to configure IntelliJ to push changes to origin/master after every commit?

Fiberboard answered 19/3, 2016 at 20:44 Comment(4)
Possible duplicate of How can I use keyboard shortcuts to do a git commit and push from IntelliJ IDEA?Thury
This is ill advised. This takes away the option of keeping certain branches local and makes the responsibility of pushing the codebase the tool's instead of the developer's.Jarad
@Thury the answer to the suggested question is Ctrl+K followed by Ctrl+Shift+K (or Ctrl_K followed by Alt+P as they say), which is what I do not want to do.Fiberboard
@Jarad we do not have any branches, we are forced to use git for trunk based developmentFiberboard
O
1

There is no option to always perform commit and push automatically. However, there is a shortcut to perform these two operations together manually. If you hover over the "Commit" button in the Commit Changes dialog, you'll see the "Commit and Push" option, which will push the changes after you commit them.

Oglethorpe answered 20/3, 2016 at 9:41 Comment(2)
thanks, it still requires Ctrl+K and Alt+P so that is even more complicated than Ctrl+K and Ctrl+Shift+K in my mind, I have tried using both for a while. Is there a plan to add it, Ctrl+Alt+K that commits and pushes for people that do trunk based development only?Fiberboard
In our environment, it does not make sense to have commit and push be separate. There really does need to be an option to tie the operations together. For us it would mean that it would be less likely to lose a commit that someone forgot to push.Coenosarc
V
1

if i work in Windows 10 with PhpStorm 2018.1 EAP, then i using this script for AutoHotkey Version 1.1.28. for commit and push with just one shortcut (Ctrl+K).

#IfWinActive,ahk_class SunAwtFrame
  ~^k:: ; thats Ctrl+K
    WinWaitActive,Commit Changes ahk_class SunAwtDialog,,3
    Sleep,300
    send,{CtrlDown}{Altdown}k{Ctrlup}{Altup} ; Ctrl+Alt+K that commits and pushes 
    WinWaitActive,Push Commits ahk_class SunAwtDialog,,3 
    Sleep,200
    send,{Altdown}p{Altup} ; push
    Msgbox,macro for git push in IntelliJ finished `n developed:SL5net, 23.03.2018 17:11`n (%A_LineFile%~%A_LineNumber%) 
  return

installer for autohotkey : https://autohotkey.com/download/

Voncile answered 23/3, 2018 at 16:20 Comment(0)
W
0

Use Git hooks.
Go to project_folder/.git/hooks.
Add file with name post-commit
Add into file:

#!/bin/sh
git push

or some specific branch

#!/bin/sh
git push master origin

Further it is enough only use Commit.

Warsle answered 27/9, 2023 at 11:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.