How to update Git Bash? - bash

I want to update bash to the latest version. How to do that? I am on a Windows 10.
$ bash --version
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
I tried:
bash --Update
didt work
bash --self-update
didnt work

Bash does not have the ability to update itself!
Software updates on a computer are limited to a super user. But Bash can be used by everybody. It does not make much sens to put the update functionality into a program, everybody can use, although only super users are allowed to do the update. This is the status quo on Unix, where Bash came from. On Windows, which came from DOS, a single user OS, the situation may be different.
Inventing non existing and not documented command line options is unrewarding. Read Bash's manual to know, which command line options are available.
It is the work of a package manager to install software and to update software. Almost every operating system has its own package manager. Even on Windows there are at least two different package managers.
If you use MSYS2, then you can update with pacman.
If you use Cygwin, then you can use its setup.
BTW: The question is off-topic here. Try it at superuser.com.

Git bash updates are not managed on windows. You are supposed to download and reinstall on each version.
see https://superuser.com/questions/1260587/how-to-disable-git-bash-daily-updates-checking
You can have a "update check " option, but no real update.

Related

newbie checking if I messed anything up in macos terminal while trying to install homebrew [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
Improve this question
I was feeling perhaps a bit overambitious in trying to follow online tutorials to install a Jekyll bundler on my Mac (MacOS Monterey 12.5.1), in hopes that I could choose from a broader range of templates in making my own GitHub pages website.
Since I couldn't get the terminal command to install Jekyll to work (some error about not having the permissions), I found another tutorial that had instructions to install homebrew so that I could then install the Jekyll bundler.
That tutorial said to enter the following text into the terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I did that and it showed me a ton of text that looked like maybe it was working (sorry, didn't save it at the time to share here).
When I put in the next line in the tutorial instructions to update brew, it just says:
-bash: brew: command not found
and when I try to check the version of brew, it does the same thing. So I don't think the install worked.
And that's fine. I think I'm going to give up on jekyll and homebrew, and not risk messing something up in my computer without knowing what I'm doing. I'm just worried about whether I already messed anything up.
The reason I'm worried is that after I put in that tutorial command to install homebrew, everytime I got the new input/command line, it had a message that began with:
"The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`."
I ran the code the message instructs. But I don't actually understand what the original command from the tutorial did. It obviously didn't do what it was supposed to do, but it also clearly did something, and I'm hoping someone who actually understands this code could let me know if there might be anything I should do to undo the effects of this all and clean up any mess I might have made in my computer. Thanks in advance!
-bash: brew: command not found
This indicates there is no program called "brew" in your PATH variable. There are a number of reasons why after an install, the command would not be available to you.
You may just need to refresh your shell cache. If this is the issue, running one of these will resolve it.
hash
rehash
Depending on whether your macOS system is Intel or M1/M2, the location of the brew binary installed changes.
Intel it is stored in /usr/local/bin/brew
M1/M2 stores it in /opt/homebrew/bin
These new paths are not in your start up scripts by default. You will need to make sure they are added.
To add them to your path, use Terminal.app or iTerm3.app:
% open .profile ; open .cshrc ; open .zshrc; open .login; open .bash_profile
The file /Users/risner/.zshrc does not exist.
The file /Users/risner/.login does not exist.
Ignore any "does not exist" errors. You should have a couple files opened with TextEdit.app
Look for assignments to "path =" for .cshrc or .login and "PATH=" for others.
Modify them to add the path you need.
Once added, a reboot or exit Terminal.app and restart should make brew be recognized as a command.
"The default interactive shell is now zsh. To update your account to
use zsh, please run chsh -s /bin/zsh."
At some point, someone at Apple decided advising older user to change from tcsh to zsh was a good idea. My guess is all new documentation will be written with zsh in mind and they'd rather we all used it. The two shells (tcsh/csh and zsh) are similar in function but quite a bit differ in other ways. For the most part, if you are not using advanced features in them, they are identical. I'd leave it at zsh unless you wish to revert back.

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.

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

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.

how can I run shell script line by line [duplicate]

I'll love something like Microsoft Visual Studio's line-by-line debugging in bash, with current variables values and so.
Is there any tool or way to do it? set -x and set -v are nice but not perfect.
See bashdb.
If it's installed on your system, see man bashdb.
If it's not installed, see http://bashdb.sourceforge.net
Yes. Use "bashdb" from http://bashdb.sourceforge.net/
Latest version at time of writing
http://sourceforge.net/projects/bashdb/files/bashdb/4.2-0.8/
If you are on a Mac (like I was) then you might need to install the GNU version of Bash.
I did that using "MacPorts"
http://www.macports.org/
Once you have MacPorts...
port install bash
Then follow the instructions to
./configure (in bashdb unpacked directory)
make
sudo make install
Then add the folder where bashdb can be found in your PATH

Resources