How to Use Git with TexStudio

TexStudio is our favorite TeX editor. It works with only SVN version system. Nevertheless, using macroses one can teach it to work with Git also. To do it, one needs to create three new scripts Macros -> Add/Change in the file menu.

Get from server

%SCRIPT
buildManager.runCommand("git pull ", editor.fileName())


Commit

%SCRIPT
dialog = new UniversalInputDialog()
dialog.setWindowTitle("Git commit / push")
dialog.add("Commited by Olek P", "Comment", "comment")
if (dialog.exec() != null) {
    comment = dialog.get("comment")
    buildManager.runCommand("git commit -a -m \"" + comment + "\"", editor.fileName())
}

Upload to server

%SCRIPT
buildManager.runCommand("git push origin master", editor.fileName())

Windows users must change path to git. For example the last script should look like following:

%SCRIPT
buildManager.runCommand("\"C:\\Program Files\\Git\\bin\\git.exe\" push origin master", editor.fileName())

Leave a Reply