TexStudio / TexMaker and Github

You can run custom commands in Texmaker (User -> User Commands) as well as TeXstudio (Configure -> Build -> User Commands). With that it should be possible to call Git command line tools from within the editor. Moreover in TeXstudio, you can combine this with scripting and triggers, which allows you to automatically trigger these actions e.g. on file save.

If you tell me which git commands you need, I could provide example code.

Edit:

Below is an example for TeXstudio, in which the commands are called via scripting. Create the scripts at User Macros -> Edit Macros.... Since I'm not into git, I don't know if the actual git calls are correct, however it should illustrate the idea.

Pull:

Git pull command

A simple plain call to an external program. On first execution of the script TXS will ask you if you trust the script to execute external programs.

Push:

Git push command

This a bit more fancy. First, the script asks the user for a commit comment. Second, the trigger ?save-file means that the script is called everytime you save a file.

Of course, you can further extend the scripts according to your needs.


There is an available script on TeXstudio_wiki for commit and push. It shows a drop menu for the user to select action of two; "commit" or "Commit with Push". You can run it manually or using a trigger like ?save-file or ?close-file

Here is the script

%SCRIPT
choisedialog = UniversalInputDialog(["Commit","Commit with Push"],"Git","choiseGIT")
choisedialog.setWindowTitle("Git")
choise = choisedialog.get("comment")
if (choisedialog.exec() != null) {
    if (choisedialog.get("choiseGIT") == "Commit") {
        dialog = new UniversalInputDialog()
        dialog.setWindowTitle("Git commit / push")
        dialog.add("Committed by TeXstudio", "Comment", "comment")
        dialog.add(true, "Commit all Files","allfiles")
            if (dialog.exec() != null) {
                comment = dialog.get("comment")
                if ((dialog.get("allfiles")) == true){
                    buildManager.runCommand("git commit -a -m \"" + comment + "\"", editor.fileName())
                }else{
                    buildManager.runCommand("git commit " + editor.fileName() + " -m \"" + comment + "\"", editor.fileName())
                }
    }
} else
    if (choisedialog.get("choiseGIT") == "Commit with Push") {
        dialog = new UniversalInputDialog()
        dialog.setWindowTitle("Git commit / push")
        dialog.add("Committed by TeXstudio", "Comment", "comment")
        dialog.add("master", "Branch", "branch")
        dialog.add(true, "Commit all Files","allfiles")
            if (dialog.exec() != null) {
                comment = dialog.get("comment")
                branch = dialog.get("branch")
                    if ((dialog.get("allfiles")) == true){
                buildManager.runCommand("git commit -a -m \"" + comment + "\"", editor.fileName())
                }else{
                buildManager.runCommand("git commit " + editor.fileName() + " -m \"" + comment + "\"", editor.fileName())
                }
                buildManager.runCommand("git push origin \"" + branch +"\"", editor.fileName())
            }
   }
}

In case you just need to commit from TeXstudio and are willing to do all things more complicate with a terminal or some other external tool, here a quick hack to get git into TeXstudio (basically by disguising it as svn):

1) In the preferences change the SVN command to you local git:

enter image description here

2) In your $HOME/.gitconfig set the following alias

[alias]
    ci = commit

3) Now you can happily commit with Check in... from the TeXstudio menu

enter image description here

This will execute the command

 /usr/local/git/bin/git ci -m "my commit message" "/pathtofile..."

4) To access this either assign a keyboard shortcut, add it to the menu bar or got to file->svn->check in...

enter image description here