8

I've installed git in /usr/local on my mac from http://git-scm.com/download/mac but I'm confused about how to open the terminal.

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Viki
  • 421
  • 1
  • 4
  • 12
  • define open the terminal? from Finder, Go -> Utilities -> Terminal. Make sure that /usr/local/bin (assuming git installed into /usr/local/bin) is in your path. OSX also comes with git, in /usr/bin so you would need to make sure that /usr/local/bin is before that in your path.. – Doon Oct 06 '15 at 15:51
  • Thanks for telling, we've to type the following in the terminal right? sudo mv /usr/bin/git /usr/bin/git-system But it has not mentioned how to make the terminal get out of git-shell? – Viki Oct 06 '15 at 15:53
  • @Doon There's a Git-Shell terminal right..That was what I asking about – Viki Oct 06 '15 at 15:55
  • @Viki You probably just need to type `Ctrl-D`. – Droppy Oct 06 '15 at 15:59
  • @Viki git-shell is a limited shell for ssh accounts that allows the commands required for push/pull to work without having to give full shell access to the computer. I do not think that is what you are looking for (but could be wrong) – Doon Oct 06 '15 at 16:00
  • Just use the normal OSX Terminal. Type `cmd+spacebar` and start typing `Terminal` and hit `Enter/Return` as soon as it guesses you want `Terminal`. The you can type `git` commands into the regular Terminal, e.g. `git status`. – Mark Setchell Oct 06 '15 at 16:06
  • @MarkSetchell Is it?! So the terminal will work with both Git and normal OS X commands? – Viki Oct 06 '15 at 16:09
  • Yes, absolutely. Just remember though that OSX comes with its own `git` already in `/usr/bin/git` so if you just type `git` you will get the OSX-supplied one. Whereas if you type `/usr/local/bin/git` you will get the one you just installed. Try it out with `git --version` and then `/usr/local/bin/git --version` – Mark Setchell Oct 06 '15 at 16:12
  • @MarkSetchell perfect! Thanks a lot.. :) – Viki Oct 06 '15 at 16:46

5 Answers5

9

Bash is shell. In mac you already got Bash but in windows you get Bash when you install git. So in mac you will use terminal for your git, but in windows you get separate git terminal. I think that's why you are confused.

when you type

git --version

if u see it is already installed so you are ready to use the git in your terminal

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
3

I use Windows, where Git bash is the application that I use to use git commands. On my mac, however, the Terminal application is used for Git commands like Git Bash on Windows. I was a bit confused as to why I could not find a Git Bash version for Mac anywhere on Git's site. It turns out that Git commands are all executed in the Mac terminal application, Terminal. As said above, first check that you have installed Git correctly with running this in the Terminal:

git --version

And then if a recent version of git is spat out from the Terminal, then you can start using normal git commands like how one would use in Git Bash, like these:

git clone YOUR_REPOSITORY

or

git checkout OTHER_BRANCH

I hope that this helped.

2

I strongly recommend you use Homebrew to install git.

  1. install Homebrew
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. install git last stable version.
    brew install git

  3. open system terminal (the Mac OS build-in terminal)

  4. run git --version, You will see It!

About Homebrew.

Shannon Chou
  • 1,367
  • 1
  • 8
  • 11
  • This is good advice - especially if you plan to use any other commandline tools, such as `ImageMagick`, `tree`, `GNU Parallel`, `gnuplot`, `doxygen`, `fswatch`... – Mark Setchell Oct 06 '15 at 16:39
  • @ShannonChou Once the built-in terminal changes to the Homebrew's git terminal, how can I revert back to the built-in one? – Viki Oct 06 '15 at 18:57
  • @Viki The `homebrew` one will be installed in `/usr/local/bin`. The Apple-supplied one will be in `/usr/bin`. So, if you want the `homebrew` one, use `/usr/local/bin/git`. If you want the Apple-supplied one, use `/usr/bin/git`. If you just want to only ever type plain old `git`, choose once which one you want that to refer to and put that first in your `PATH`. – Mark Setchell Oct 06 '15 at 19:32
  • @Viki Homebrew and git are not terminals. They are command line tools that you can use in terminal. So, Installing Homebrew and git does not change the terminal. You can use Homebrew to install other command line tools. It's like yum or apt-get in linux. The Mac built-in git is an old version. You won't need it anymore after you installing new one. – Shannon Chou Oct 07 '15 at 01:51
0

It sounds like you have not performed steps 2 and 3 from the README.txt file:

Step 2 - Remove stubs

In later versions of OS X (Yosemite and onward), you'll probably see a message like the following:

'The "git" command requires the command line developer
tools. Would you like to install the tools now?"

This is because OS X has started to ship with stubs; in order to stay nice and easy-to-uninstall, the git installer places all of it's assets under /usr/local/git. As a result, the git in /usr/local/git/bin/git takes second place to /usr/bin/git.

sudo mv /usr/bin/git /usr/bin/git-system

Step 3 - Restart bash sessions

This include GNU screen sessions, TMUX sessions, etc. If you wish to preserve your precious screen session, just source /etc/profile.

Droppy
  • 9,691
  • 1
  • 20
  • 27
  • El capitan (10.11) has SIP enabled so you will not be able to mess with /usr/bin anymore.. – Doon Oct 06 '15 at 15:53
  • @Droppy my question is similiar to this except that we've downloaded from different sources. http://stackoverflow.com/questions/4725389/how-to-get-started-with-git-on-mac Coming to the README.txt file, I didn't notice any message and also I'm TOTALLY new to this stuff. Please help me out! – Viki Oct 06 '15 at 16:06
  • But in your question you state you downloaded it from http://git-scm.com/download/mac. So what gives? – Droppy Oct 06 '15 at 16:10
  • @Droppy as I've said in the previous comment, "my question is similiar to this except that we've downloaded from different sources." – Viki Oct 06 '15 at 16:12
  • @Droppy Btw MarkSetchell has told that the terminal could be used for both git and normal OS X commands! I think that solves the problem.. – Viki Oct 06 '15 at 16:14
  • And this is news to you? – Droppy Oct 06 '15 at 16:15
-2

On your command line, type "git" then cd to the directory where your project resides.

Hexana
  • 1,095
  • 2
  • 12
  • 35
  • 1
    Typing `git` will just give an error message about usage. It doesn't do anything useful. –  Oct 06 '15 at 15:52