When you say that "git was somehow uninstalled", I assume you mean you cannot use the command git
and you get -bash: git: command not found
error. So the following should help.
Is git
installed?
The first thing to do is type which git
and that will tell you if its included in your path. If nothing is prints, then you know thats your first problem:
- It's not installed, or
- It is installed, but not included in your
$PATH
.
The solution to these problems, obviously, is install it or find it on your system. Typically on Mac OSX, it is found in /usr/bin/git
. Add it to your $PATH
like so:
export PATH=/usr/bin/:$PATH
in your .bashrc
or .bash_profile
(substitute /user/bin
with the directory where you find git
. )
Does the git
repository still exists?
Now, check that the is repo didn't get destroyed. Most likely, it did not.
$ cd project/
$ ls -la
drwxr-xr-x 3 user staff 102 May 24 18:31 .
drwxr-xr-x 6 user staff 204 May 24 18:31 ..
drwxr-xr-x 9 user staff 306 May 24 18:31 .git
-rw-r--r-- 1 user staff 119 May 24 18:34 README.md
The presence of the .git
directory means it still exists, therefore finding/installing git
is your only problem. As soon as you fix that problem, you should be able to use git
exactly how you used to.
However, if the .git
file is gone (highly unlikely), there are several things you can do.
- If you know your directory was in a clean state (all committed changes) and pushed to github before your loss, you can just delete the directory on your local machine and pull in a new fresh copy of the repo (easiest).
- If you know your repo was clean, but NOT pushed to github OR you had a dirty directory (with changes not committed), you are in a bad spot. However, it is not impossible to regain your repo to its original state. Without knowing your repo directory structure, I can't go into too much detail. But the following should work for most cases:
- Initialize a new repo in the project directory.
- Add all files and commit.
- Add the remote repository
- Pull down the repo to merge them together.
- Resolve conflicts.
Good luck :)