Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command to open file with git

Tags:

git

  • I have sublime text as the default editor in git (and it works)
  • git config --edit opens the config file in sublime text (Awesome)

My Question:

What is the command to open say index.html or style.css from inside the project directory?

Basically when I'm working on a project I would like to be able to open a file from git. How to do this. Every tutorial seems to go over merge, clone, commit yes we all know these, how to do this simple command. Or is this not possible from within git?

  • windows 7
  • msysgit version 1.8.0

I understand git is not a launcher and is strictly for version control. Just want to know what options I have with the tools at hand.

The question came up while i was commiting a project and realized i needed to make a small edit to a css file i had closed already and was wondering if i could open to edit the file from within git since i had it up.

Seems this is not possible (not the end of the world) I just like to understand all of my options with the tools i use is all

like image 454
Danferth Avatar asked Dec 15 '12 00:12

Danferth


People also ask

How do I open a file in Git?

Step 1: Go to Github repository and in code section copy the URL. Step 2: In the Command prompt, add the URL for your repository where your local repository will be pushed. Step 3: Push the changes in your local repository to GitHub. Here the files have been pushed to the master branch of your repository.

How do I open a file from command line?

To open any file from the command line with the default application, just type open followed by the filename/path.

How do I open a Git file in a specific folder?

Using Windows Explorer, navigate to any directory you want, type "cmd" in the address bar it will open Windows command prompt in that directory. Along the same lines, if you have the git directory in your path, you can type "git-bash" in the address bar and a Git Shell will open in that directory.


2 Answers

Git has nothing to do with how you open/edit files in your project. Configuring the editor in git is only so that git internal things that require an editor (commit messages for example) can use your preferred editor.

If you just want to open files from the command line (cmd.exe) as if they were double clicked in the windows explorer, I think you can use start <filename>.

like image 163
Brenton Alker Avatar answered Sep 25 '22 03:09

Brenton Alker


I was able to do this by using this command:

notepad .gitignore 

And it would open the .gitignore file in Notepad.

like image 28
Nick Young Avatar answered Sep 25 '22 03:09

Nick Young