0

I'm new to git and following a tutorial and want to use it with Sublime Text 2. I installed the Git package, and the tut says that if I open the command palette (ctrl+shift+p) I will be able to see all the git commands, but I only see Git: Init and Git: Commit history. Do I first have to go into my repository/folder? If so, how would I do that? Right now I am on a new file which I assume is why I can't see any Git commands.

Also, I want to make SB2 my default editor, and I tried this code in my command line (using git bash). Is anything supposed to happen? How do I know if it worked? And what if I wanted to revert back to the command line (git bash) instead of SB2?

Community
  • 1
  • 1
vytfla
  • 549
  • 2
  • 9
  • 29

1 Answers1

1

To answer the first part, you can do this by opening the folder in SB2:

  1. File -> Open Folder...
  2. Open your local git repository (The directory where the .git file is located)
  3. Commands like 'Git: Add all' should be available via cntrl+shift+p

To answer the second part, the code you entered is for when you want to use git bash as your git client. This code will set up SB2 as your text editor for git bash. If it worked, the next time you make a commit in git bash, just type 'git commit' and SublimeText2 should open up, to where you can enter your commit message.

If you need to revert back your core.editor to default, look at the following: Git: How can I reset a config parameter after I have accidentally changed it?

To try and answer your comment,
What's the difference between git bash and the git plugin for SB2?
They are just different ways to interact with git and git repositories. Thus you would use the SB2 plugin as a replacement for git bash. This means you would be doing all the git commands (git add, git commit, etc) via the command palette in SB2, rather than as a command line via git bash(and thus no, you would not have to always start with git bash until you 'git commit'). If you wanted to use the git plugin for SB2, you wouldn't need to make SB2 your default editor for git bash(second part) as the plugin will always use SB2 for this purpose.

If you want to interact with git via git bash instead of the SB2 plugin, you would not need to install the git plugin on SB2. To give some background information, by default Git Bash usually uses a command line text editor(VI or VIM(https://en.wikipedia.org/wiki/Vim_(text_editor))). Git Bash will then use this text editor(VIM for example), when it needs user input(like when you enter 'git commit'). If you are not familiar with these text editors you can change the editor git bash uses(core.editor) to something like SB2((second part)the code you entered in git bash).

This is entirely my opinion, but I think it would be simpler just to start out by learning to use git via git bash as then you can more closely follow git tutorials like the following(which is a good place to start): http://git-scm.com/docs/gittutorial. Also, you then can still use SB2 to edit the files within your git repo, though aren't restricted to only using SB2 and can use any text editor or IDE in the future with git bash.

Community
  • 1
  • 1
Cad
  • 374
  • 3
  • 6
  • Great, thanks, the first part worked inside SB2. I'm a little confused about the second part- what's the difference between using git bash vs. SB2? Do I always have to start with git bash until I 'git commit' at which point it'll go to SB2? I guess this is where my inexperience shows, might be better to just stick with git bash. – vytfla Feb 10 '16 at 00:08
  • I have added additional information to the answer to try and answer these questions. Please let me know if you still have questions. – Cad Feb 10 '16 at 01:45
  • Amazing. Thank you so much. – vytfla Feb 10 '16 at 23:38
  • One more thing actually. I am able to open SB2 via git bash by typing in "sublime_text"; I added the path to the exe (sublime_text.exe) in system > advanced system settings > environmental variables > Path system variable. Is there anyway I can shorten 'sublime_text' to something else? Or is it whatever my .exe is called? – vytfla Feb 11 '16 at 00:18
  • I believe you are only supposed to have directories within your path, so make sure you don't actually include sublime_text.exe within your path, just the directory that it is contained in. I think it is whatever your .exe is. If you want to open up sb2 via git bash with a shorter name, you could create a directory for startPorgramShellScripts, then add that directory to you path. Then create a shell script(named sb2 for example)(file with no file extension) and in that shell script put the full path to sb2 in quotes: ".../sublime_text.exe". Open bash and type sb2. It should open. – Cad Feb 11 '16 at 01:29
  • Understood. Thanks again. Learning I can just tab to auto-fill, so no real issue. – vytfla Feb 11 '16 at 01:46