How do I install Git for Windows software to a specific directory? - windows

I have just downloaded the latest Git for Windows installer, v2.4. It appears to want to install to the standard Windows "Program files" (with-spaces-in-name) directory.
Since I have all my development code in a folder called (simply) "/bin" -- I want to see if there's a command line option or parameter to change the install directory.
In my case, these days I use a environment variable such as GIT_HOME for important software like git; so it would be useful if there was a way to apply that to things like git commands, etc once I have the program installed.
possibly related:
How do I change the directory in Git Bash with Git for Windows?
I also came across a few questions asking: "whereis git". That's answered above, however I take that as an indicator that others may want git somewhere else too.

To start the installer with a different installation path you can open a CMD terminal in the same directory as the installer executable and pass in an option parameter of /DIR="x:\dirname"
For instance, if you have version 2.17.0 for Windows 64bit and you want to install git to D:\git, you would run:
Git-2.17.0-64-bit.exe /DIR="D:\git"
The installer will launch as usual and you need to walk through the other options, but the install location will be the path specified.

Since I just ran into this problem because my SSD is filling up, I figured I'd share the solution I came to on Windows 11 with Git v. 2.37.2.
The best way I could figure was to uninstall Git, then in CMD Prompt use the suggested command from the Git website with an appended --location/ -l flag:
winget install --id Git.Git -e --source winget --location [drive:/directory]
where [drive:/directory] is your target for the install. Had no issues and verified it worked with a project.

Related

How to install git on Windows 10 without Git Bash or GUI?

I am trying to install Git on Windows 10, but without Git Bash or GUI. I want to use Git in PowerShell and I would like not to bloat my PC. I know the install size is small, but that's not the issue.
I've tried going through the installer from git-SMC/Git for Windows a couple times, but it appears I can not opt out of GUI and Bash. Any idea how I can do this? Perhaps Chocolatey is of any use?
Thanks in advance!
You can use MinGit
MinGit is provided on the Git for Windows repository
https://github.com/git-for-windows/git/releases
It does not come preinstalled with Git Bash, GitK or Vi etc.
The github repo publishes portable and minimum versions of the binary releases which don't require installation. You could prune out the parts you don't want if you need to cut it down further.
https://github.com/git-for-windows/git/releases
Or instalation Using Chocolatey, if that will be ok for you
https://www.jamessturtevant.com/posts/5-Ways-to-install-git-on-Windows/#using-chocolatey
I started with Git and then removed everything except the following dirs:
\mingw64\libexec\git-core
\ssl
Rename git-core to cmd and move it up 2 levels and you don't even have to edit your .gitconfig.
Works like a charm for me.

sudo command not found on Cygwin

I am currently trying to install and update a few packages on a Windows OS. The only matter is that I am using Cygwin in order to type the commands through a terminal (as I'm aware, I can type in Linux type commands such as cd, ls etc. on Cygwin - I may be wrong). However, when I try to install a package like:
sudo apt-get install paparazzi-dev
I get the reply:
-sh: sudo: command not found.
Does anyone have an idea as to how I can fix this problem?
Run cygwin as administrator.. then you wouldn't need any sudo command.
Cygwin is not a full Linux distribution. Therefore you don't have sudo or the Debian/Ubuntu package manager apt-get. There is a number of packages available from the Cygwin repository: http://cygwin.com/packages/
You have to chose these packages during setup.
Windows does not have sudo, apt, or almost any Linux commands to be exact. Cygwin may allow some, but as programs are not installed on Windows as packages apt-get will not work. Windows programs have installers as .exe or .msi instead.
The Windows version of sudo is called runas in case you need to run something as another user. Or, you can run Cygwin as administrator.
If you have to use the packages you need Linux. You can install it directly to replace Windows, dual-boot or use a virtualization software like VMware VirtualBox.
Making out an explanatory answer from answer here by #Aimal as it worked for me.
Cygwin may not get permissions to create folders and files when run by clicking Cygwin icon that's in normal mode.
Cygwin gets the right authorization only when right click -> "run as adminitrator" on cygwin icon because of that it gets permissions to create folders and files.
Cygwin lets you run certain commands, such as cd, ls, or mv; but it doesn't let you run other commands, such as sudo or apt-get.
If you're trying to add a package to your Cygwin installation, rerun Cygwin Setup. It may still be in your "Downloads" folder. Go through all the steps again. The Cygwin installer will automatically download and install the package you want, and add it to your Cygwin installation. (I think it will probably also upgrade all your other installed Cygwin packages to the latest available versions.)
If your desired package isn't on the Cygwin package list but is on the Cygwin Ports package list, follow the Cygwin Ports installation instructions. Note that Cygwin Ports is separate from Cygwin. Please do not send messages about Cygwin Ports packages to the cygwin.com mailing lists.
If you have years of Linux experience, you may be able to compile the software you want inside Cygwin. This can be challenging.
Perhaps an option simpler than "compile it yourself" is this: You can install VirtualBox, then install your favorite Linux distribution inside the virtual machine, then install your desired package inside Linux. (I like Ubuntu Linux, which has more than 27,000 packages in its "Universe" repository.) Now you can run Linux and Windows at the same time.
I think I tried steps below after doing some research & succeeded (on windows)
1.Install scoop using powershell 3 (iex (new-object net.webclient).downloadstring('https://get.scoop.sh'))
2. do scoop install --global sudo
3. make sure paths (C:\Users\\scoop\shims & C:\ProgramData\scoop\shims) added in environmental path variable.
In my case, I wanted to install curl, but could not create directory /usr/local/curl/lib when running command "make install", because of permission deny. so i need to change /usr/local permission. when i run sudo chmod 755 /usr/local, sudo command not found.
after searching a few solution, found that sudo is not installed by default in Cygwin. But I tried the solution that Aimal gave which is to run Cygwin as administrator. I finally can change the folder permission. Thanks Aimal.

git is not installed or not in the PATH

Windows, when I try to run npm install, it shows:
mean#1.0.0 postinstall E:\mean
node node_modules/grunt-cli/bin/grunt install
Running "bower:install" (bower) task
Fatal error : git is not installed or not in the PATH
npm ERR! weird error 1
npm ERR! not ok code 0
What is the problem? How to fix it?
The project git repository is https://github.com/linnovate/mean
Did you install Git correctly?
According to the Bower site, you need to make sure you check the option "Run Git from Windows Command Prompt".
I had this issue where Git was not found when I was trying to install Angular. I re-ran the installer for git and changed my setting and then it worked.
From the bower site:
http://bower.io/
while #vitocorleone is technically correct. If you have already installed, there is no need to reinstall. You just need to add it to your path. You will find yourself doing this for many of the tools for the mean stack so you should get used to doing it. You don't want to have to be in the folder that holds the executable to run it.
Control Panel --> System and Security --> System
click on Advanced System Settings on the left.
make sure you are on the advanced tab
click the Environment Variables button on the bottom
under system variables on the bottom find the Path variable
at the end of the line type (assuming this is where you installed it)
;C:\Program Files (x86)\git\cmd
click ok, ok, and ok to save
This essentially tells the OS.. if you don't find this executable in the folder I am typing in, look in Path to fide where it is.
Installing git and running npm install from git-bash worked for me. Make sure you are in the correct directory.
Install git and tortoise git for windows and make sure it is on your path, (the installer for Tortoise Git includes options for the command line tools and ensuring that it is on the path - select them).
You will need to close and re-open any existing command line sessions for the changes to take effect.
Then you should be able to run npm install successfully or move on to the next problem!
In my case the issue was not resolved because i did not restart my system. Please make sure you do restart your system.
If you installed GitHubDesktop then the path for git.exe will be ,
C:\Users\<'Username'>\AppData\Local\GitHubDesktop\app-1.1.1\resources\app\git\cmd
Add this path to the environment variables by following,
** (Note: \cmd at the end, not \cmd\git.exe).**
Navigate to the Environmental Variables Editor and find the Path variable in the “System Variables” section. Click Edit… and paste the URL of Git to the end. Save!
Now open a new cmd and type command git. If you are able to see the git usage then it's done.
Now you can execute your command to install your package.
ex: npm install native-base --save
Use Git CMD instead of using Win CMD.
I did install git and tried again and got the same error. But running 'npm install' in a new command prompt window worked for me. Restarting the machine is not required.
Go to Environmental Variables you will find this in Computer Properties->Advance system Setting->Environmental Variables -> Path
Add the path of your git installed int the system.
eg: "C:\Program Files\Git\cmd"
Save it.
Good to go now!!
The issue depends on the command prompt you are using. if you are using your Windows cmd, then it will be fine if you have installed git in your system (note that after installation it gets added to your system path). if you are running on an Anaconda terminal or any other, then you need to install git on your project environment from the terminal.
for anaconda, the problem gets solved by running:
conda install git

Installing Git separately from Github for Mac

I've installed Github for Mac.
I've realised that I need to get to the command line to do some stuff.
There is an option in Guthub for Mac to install a command line. All this seems to do is create an alias called Github in /usr/local/bin that points back to the Github for Mac application.
Double clicking it opens a terminal window and then Github for Mac.
Any ideas how to get Git to work in a command line?
Its a relatively clean version of Lion OS X
Git is included in the command line tools package provided by Apple that can be downloaded at https://developer.apple.com/downloads/index.action
It is also included with Xcode, which can be downloaded from either the Mac App Store or from the above link.
Assuming you'd rather not install either of these you can also obtain Git by downloading it from http://git-scm.com/downloads
Hope that helps.
https://help.github.com/articles/set-up-git#platform-mac
Should walk you though installing it.
I highly recommend installing Homebrew, which does a great job of keeping up with the latest git releases.
Once Homebrew is installed, it's as simple as:
brew install git
Note that, from May 2013, you now have with "GitHub for Mac" both:
the GUI
the CLI (Command-Line Interface)
See the blog post "Installing Git from GitHub for Mac"
you can now easily install Git for use on the command line, without needing to download any separate packages.
Even the git updates are taken care for you:
And whenever we update the version of Git included with GitHub for Mac, you'll get the changes automatically – no work required on your part!
you may notice some changes to the Preferences window.
On the newly renamed "Advanced" tab, simply click "Install Command Line Tools".
You'll be prompted for an administrator password so that Git can be installed into /usr/local/bin, and then you should very shortly see that it succeeded:
GitHub app create many links in /usr/local.
Use this command to find all link files from GitHub.
ls -l $(find /usr/local -type l) | grep GitHub.app | awk '{ print $9}'
then rm them.
PS: GitHub also created some directories that cause error when run brew link git,
e.g. /usr/local/share/git-core, /usr/local/lib/perl5/site_perl.
You should remove them carefully.

Install Git separately from Xcode

Firstly apologies if this is a really simple question but Git is absolutely brand new to me. Basically I've been dabbling with a bit of iOS development for a little while and now have a project idea that I want to start working on and for the first time I'm planning on putting this into source control.
Now I know Xcode 4 has some Git integration but I've spotted a couple of posts that suggest the integration isn't that great and it's better to do it the command line way.
So, I've been following instructions here http://git-scm.com/book/en/Getting-Started-Installing-Git and I've downloaded version 1.7.10.3 for Mac and ran the install.
However when I run git --version I get version 1.7.4.4 which is the version that was installed with Xcode I assume?
My question is, how do I make use of my new version 1.7.10.3? The plan is to learn to use Git via command tools and set up a central repository on a server I have at home, then have local copies on my laptop.
As I say I'm really new to this, so a quick step by step idiots guide would be helpful. I have searched and tried to find details here and on google but other than the suggestion to use Git outside of Xcode I've not found out exactly how to do it.
Any advice, or links to a decent tutorial that covers this would be very much appreciated.
Update:
I've changed the path to the new path in .bash_profile (/usr/local/git/bin) and now get git version 1.7.7.5 (Apple Git-26). This still appears to be the wrong version (although this could be me being dense). I downloaded the installer for OSX from the above link. Should I be doing something else. I want to play around with the command line tools so I can get a proper understanding
Update 2:
I'm now also trying MacPorts as recommended in the article. This seems to be downloading a lot more than just Git though
Xcode installs git in /Applications/Xcode.app/... but if you run 'Install Command Tools' then git gets installed also in /usr/bin/git. Xcode uses its private version in Xcode.app. If you installed git in /usr/local/git/bin then you need to include that directory in your PATH. You should have a .bashrc file (or equivalent for whatever shell you are using). Add
PATH=/usr/local/git/bin:$PATH # your shell might use different syntax.
to that file 'rc' file.
Also, note that Xcode would allow you to accomplish your goal of setting up a remote at home while maintaining a local copy on your laptop. Go to the Xcode 'organizer' and click 'repositories'. There you will find all your machine's Git repositories. Choose one, select the 'remotes' folder and then '+' to add your home remote. I use Xcode this way.
Credits goes to #GoZoner for the answer. I'm just summing up everything.
Download official git installer from : http://git-scm.com/download/mac
Install and add its directory to your path :
echo "PATH=/usr/local/git/bin:\$PATH" >> ~/.bash_profile
source ~/.bash_profile
The best way is:
step 1:
Install homebrew on your mac this is the official website Homebrew homepage
From a Terminal prompt:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
step 2:
From a terminal prompt
brew install git

Resources