How can I implement a fast install of git using sh? - macos

I need to get a classroom full of students to install git on their computers quickly and during a lecture. I've been inspired by the installation process of meteor to try and implement something similiar, i.e:
curl easy-install-git.com | sh
I know there already exist binaries and easy ways to install git, but those are all multi-step processes and this would be one simple command in terminal. How do I write an sh script to do this? (Or better yet, does one exist already?)
Any other easy ways to do a git install on a clean machine would also be appreciated.

5 years later, the easiest/fastest way to install Git on Mac is to type:
git --version
If you don’t have it installed already, it will prompt you to install it.
But that is an old Apple fork of Git (2.10 at most)
The git-osx-installer dmg files are up-to-date, with Git 2.18.
As seen in this script, it can be curl'd.

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.

How to enable auto-completion with Git [all platforms]

How to enable auto-completion with Git?
When using Git on different platforms, auto-completion is not always enabled/available.
Note that this question is NOT a duplicate of git auto-complete for branches on the command line, because that question was only about Apple users. This question is mostly the same, but including other platforms too.
You need to get bash's programmable completion configured to return the possible commands. You can see the "Programmable Completion" section in the bash man page if you want to implement it yourself.
A much easier method to use a script to pre-configure bash's programmable completion. On most distributions, the file for git completion, /etc/bash_completion.d/git (on Fedora and derivatives), /usr/share/bash-completion/completions/git (on Debian and derivatives) (other distributions might have it in other places, try locate or find to locate it) are provided by the git package. (If it is not included with your git package, you can get it from here).
You can configure bash to source the file when it is started (probably using .bashrc), or you can install bash-completion, which will automatically load completions like the one that the git package installs (and generally completions from /etc/bash_completion.d/ or /usr/local/etc/bash_completion.d/ (typically BSDs)). On most distributions, bash-completion should be available in the repositories and you can simply install the package. For other systems, see the instructions included in the README.md to install it. (On non-GNU/Linux systems, some completions might need to be disabled to prevent it from outputting errors when starting)
Apple users
See question git auto-complete in the command line
Linux users
Solution tested with Debian 9 (Stretch)
sudo apt install bash-completion
Pros:
Very easy for newcomers to Linux/scripts
No "manual" downloading
Only makes use of the official repos: the "safest" way.
Easy to update: sudo apt update then sudo apt upgrade
I also know that the question was asked for Apple users, but it shows up first in Google for "git auto-completion branch", so I thought a Linux answer would still be useful.

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

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.

Please suggest another fastest way for Migrating SVN repository to GIT respository

Downloaded the Ruby Installer for Windows and installed the latest version with Add Ruby executable to your path.
Installed svn2git.
Start menu ->All programs -> Ruby -> Start command prompt with ruby
Then type “gem install svn2git” and enter.
Migrate subversion repository
In Ruby command prompt gone to the directory where the files to be migrated
Then used the below command
svn2git http://[domain name]/svn/ [repository root]
It is taking around 2 days to migrate 20K commits into GIT and in SVN we have around 65K commits.
Please let me know is there any other fastest way to migrate the SVN repository to GIT repository.
You can try the github importer:
https://help.github.com/articles/importing-from-subversion/
I don't have any information on speed though.
Not sure what does svn2git do, but with the standard git-svn we noticed substantial slowness on the windows machines, especially annoying when doing the initial import indeed. There were two ways to solve it: performing the import on macos/linux machine and then simply copying the resulting repo onto the windows workstation or partial import (git svn fetch -R <recent revision>).

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