How to install Git Large File Storage on Windows? - windows

According to its doc, double-click should be enough. But when I opened git bash and ran git lfs init, it doesn't work:
$ git lfs init
git: 'lfs' is not a git command. See 'git --help'.

The only reason why "git lfs" would not be a git command would be because the git-lfs.exe hasn't been put in your %PATH%.
That is what the git-lfs-windows-amd64-0.5.3\install.bat is supposed to do.
set GIT_LFS_BIN_PATH="%LOCALAPPDATA%\GitLFS\bin"
IF EXIST %GIT_LFS_BIN_PATH% GOTO DIRECTORY_EXISTS
mkdir %GIT_LFS_BIN_PATH%
set "path=%PATH%;%GIT_LFS_BIN_PATH:"=%"
So:
Make sure install.bat was successfully executed
Check the content of "%LOCALAPPDATA%\GitLFS\bin"
make sure to open a new CMD Windows
Check your %PATH% environment variable

Just adding my 2c in case someone lands on this page..
The easiest (and I believe most "correct") option to install LFS on Windows is to use the windows' built-in winget package manager
winget install -e --id GitHub.GitLFS
I was getting the same error as you after simply running the downloaded installer, however the winget command fixed it for me.
PS. Even if you don't have winget - running winget will automatically install it from MS Store

Related

How to change the command base in Git Bash in VS Code?

I'm learning to use Git. After installation I can open a Bash terminal on VS Code (I'm using Windows if that's relevant). Right after opening a Bash terminal, this command shows up automatically (the id and path are masked for privacy):
myid#machineid MINGW64 /c/Users/...
$ source C:/ProgramData/Anaconda3/Scripts/activate base
(base)
I guess it means it's using Anaconda to run the Git command. However, it appears many CMD commands that otherwise work normally in a Windows terminal don't work. For example, I can't create a new folder. This error comes up:
$ mkdir test
bash: /c/ProgramData/Anaconda3/Library/usr/bin/mkdir: Permission denied
(base)
Similarly, commands like ls or touch just don't work. But I find pwd works. I look at /c/ProgramData/Anaconda3/Library/usr/bin and see there are a bunch of CMD command exe files in there, such as mkdir.exe, rm.exe. I also look at the Git installation directory and find a folder with similar exe commands (C:\Program Files\Git\usr\bin)
On the other hand, I can still use Git commands. So this works (after manually creating the folder test):
$ git init
Initialized empty Git repository in C:/Users/.../test/.git/
(base)
Also, if I don't use VS Code, but use a Git CMD then everything works just fine.
So the question is how I can fix it? More specifically, how can I direct Git to use Git command base in VS Code instead of depending on Anaconda base? What it currently means to me is that if I uninstall Anaconda then Git may not work in VS Code at all.

Git "add --patch" is not working

When I type git add --patch on my Windows 10 machine in the terminal, I get the error:
git: 'add--interactive' is not a git command. See 'git --help'.
I've googled to no avail, all other problems seem to be people running into this issue using other software or on Linux. Any tips?
This thread (for Git on Linux) mentioned the lack of a git-perl package.
But that should not be the case on Windows.
For testing, download PortableGit-2.17.0-64-bit.7z.exe and uncompress its content anywhere you want.
Then setup a simplified PATH:
set G=c:\path\to\latest\git
set PATH=%G%\bin;%G%\usr\bin;%G%\mingw64\bin
set PATH=%PATH%;C:\windows\system32;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\
In that CMD session, try again your git add -p command.

How to get docker 'objects' completion on mintty-bash from git for windows

I have read (and tried) this:
https://docs.docker.com/machine/completion/
But it seems this is not the right way to get it on.
Anybody know how to get docker completion commands in Mintty (from Git for windows) bash command line?
Not sure if this is the best way to do this or if it work properly at all, but it seems to work!
Let me know if you find any strange behavior...
Minimum requirements:
Git for Windows (git bash / mintty terminal)
7-Zip or similar to extract files
Installation:
First of all, you will need the bash-completion package.
I discovered that the package built for cygwin works.
Choose a cygwin mirror: https://cygwin.com/mirrors.html
Navigate to: /cygwin/noarch/release/bash-completion/
Download: bash-completion-2.7-1.tar.xz
Extract it elsewhere
Copy the etc and usr folder to C:\Program Files\Git (see the note below)
Done, now you should have command completion enabled.
Testing:
You can test it by opening a git bash terminal and typing:
curl --ver (hit tab twice)
It will suggests something like this:
$ curl --ver
--verbose --version
Docker commands:
Now, about that docker commands...
I have found my files here:
docker command:
https://github.com/docker/docker-ce/blob/v17.09.0-ce/components/cli/contrib/completion/bash/docker
docker-compose command:
https://github.com/docker/compose/blob/1.16.1/contrib/completion/bash/docker-compose
docker-machine command:
https://github.com/docker/machine/blob/v0.12.2/contrib/completion/bash/docker-machine.bash
Just download and copy them to:
C:\Program Files\Git\usr\share\bash-completion\completions\
Make sure they are correctly named (remove the filename extension if any).
It should be named like this:
docker
docker-compose
docker-machine
No extra .txt or whatever...
Some notes:
I'm not sure if the package bash-completion-2.7.1 is the best version to work with git bash, I just got the latest one. (You can compare them and find it out)
You don't need to copy all the files from /usr/share/bash-completion/completions/, just the ones you want. (I didn't copy any of them).
It's a good idea to run a docker version, docker-compose version, docker-machine version and check the versions you are running, then download the correct files from the repository. (Choose the correct release tag for you).

Commands don't work in Git bash but work in Windows command

I installed Ruby, and I installed git.
When I right-mouse click, I can run Git bash.
But commands like
git status
or
gem install ~~~
don't work there. But they perfectly work fine with Windows command.
But commands like
heroku login
doesn't work both in windows command and git bash. I get the error message
bash: heroku: command not found
Is there something that I need to connect git bash with these commands?
1.9.5 is now obsolete.
Uncompress PortableGit-2.5.0-64-bit.7z.exe anywhere you want, and add C:\path\to\PortableGit-2.5.0-64-bit\bin to your %PATH%.
Also, call C:\path\to\PortableGit-2.5.0-64-bit\git-bash.exe to test a bash session, in which git will be recognized.
Make sure your %PATH% also includes the path for ruby.

Permission denied when creating symbolic links in git

there is a similar question, but the difference here is that I am working on Windows. I am running git on Windows (working in git bash tool) and I have successefully cloned my forked repository. Now I need to make symbolic link and it gives me Permission denied. I can make new dir for example in .git folder and I have also set chmod /R 777 for .git directory, so it seems I have permissions.
I tried to run:
rm -rf hooks and then ln -s ../git_hooks hooks.
You might be running into a basic incompatibility of ln on windows platforms (in this case within MINGW-MSYS). You can replace ln with a version that "does the right thing" on Windows; have a look at this:
Git Bash Shell fails to create symbolic links
I had this issue on Windows and I did a couple of steps to resolve this :
Enabled core.symlinks by modifying git config
git config --edit
Opened Git Bash as an Administrator and executed the git checkout command
This worked for me, hope it helps someone.
If you have are using Git for Windows SDK, you can install winln using the pacman package manager by running: pacman -Su winln
Then you can run: winln -s target link, it will check that you have SeCreateSymbolicLinkPrivilege, otherwise it will fail. This is equivalent to running Window's mklink.exe.
I am surprise Git for Windows, does not ship with winln vs an ln command that does a copy without telling you that it did a copy.
When installing git-bash for windows, there is an option called "Enable symbolic links". When I installed git-bash with that option I had the same issue as OP. So I installed the same setup (git-bash) again with that "Enable symbolic links" option unchecked. Then my issue was resolved.
If you are using a local web server on Windows (OpenServer, Laragon, Local), then start the server as an administrator. It worked for me

Resources