Command to open file with git

后端 未结 18 1283
滥情空心
滥情空心 2021-01-30 04:05
  • I have sublime text as the default editor in git (and it works)
  • git config --edit opens the config file in sublime text (Awesome)
相关标签:
18条回答
  • 2021-01-30 04:38

    Brenton Alker above said 'start ' works -- I'll add a caveat to that: that works for all files that are already associated with sublime-text (as he says, it works as if they were double clicked in windows explorer).

    But if, for example, you wanted to open the .gitignore file from your shell into sublime_text, and .gitignore is not associated with sublime_text, here's what I did:

    I edited my PATH environment variable to contain the Sublime Text folder within program files, the one that holds sublime_text.exe. Now, in my terminal (I use powershell, but it works from any terminal), when I type 'sublime_text .gitignore' the .gitignore from my current directory opens in Sublime!

    I tried to make a .bat file called sublime.bat that would work so that I could just type sublime .gitignore, but that didn't work - it opened sublime text but not the file for some reason. I'm content with sublime_text (tab completion simplifies it for me, actually -- simply 'su[tab]' does the trick!

    0 讨论(0)
  • 2021-01-30 04:38

    To open a file in git, with windows you will type explorer . , notice the space between explorer and the dot. On mac you can open it with open . , and in Linux with nautilus . , notice the period at the end of each one.

    0 讨论(0)
  • 2021-01-30 04:39

    To open a file in Sublime Text,

    Here is an example for opening a sample text file in Sublime Text editor

    subl <filename>.txt
    

    subl is previously created as an alias name,containing the directory file, using the "echo" command in Git Bash shell.

    0 讨论(0)
  • You can use the git command line as a terminal my dude you just know the commands are bash To create a file

    touch file.txt
    

    To open a file

    code file.py 
    atom file.py
    start file.py
    

    ect

    To open your current folder and everything inside of it in your text editor

    code . 
    

    To make a folder

    mkdir folder1 folder2 folder3 
    

    You can make as many as you want at once this works with touch to

    0 讨论(0)
  • 2021-01-30 04:43

    I just downloaded Git 2.7.0 and added an alias to the .bashrc for editing files with VS Code:

    alias code='/c/Program\ Files\ \(x86\)/Microsoft\ VS\ Code/bin/code.cmd'
    

    Should also work with other Editors...

    0 讨论(0)
  • 2021-01-30 04:44

    while you are working in some whatever project and you want to make a minor change you can use git default editor, however you'd probably need a little script that parse the file generated by command below

    git config -l
    

    then the variable code.editor holds the value /Applications/Sublime_Text.app -n -w

    which you can open using os.system()

    0 讨论(0)
提交回复
热议问题