Git Bash or Git Shell , which is better for Windows? - windows

I'm learning about git form a video tutorial that uses git bash and i have downloaded GitHub for windows along git shell.which is better to use in windows and is there any differences in command lines between these?

If you would like to learn the git commands by heart. Go for Git Shell. If you someday switch over to a unix system, it would be much easier for you

Related

Run shell script in WSL with \r\n

I have a Python project which is a bunch of Docker containers and terraform scripts. My workstation is Windows 10 so I have installed Ubuntu in WSL to develop it. The problem I am facing is there are a lot of shell scripts (.sh) that I need to run as the build process. In Git it always checks out the files as Windows style and commit files as Unix Style. As a result, the Ubuntu bash shell does not like these shell scripts and I have to run dos2unix before running a file. Is there a one liner that allows me to run these scripts without modifying them?
If the scripts don't call another script you could
tr "\r\n" "\n" script.sh | bash
But in the other case I think you need to change your repository config to tell git to don't convert files with .sh extension. Look at this answer https://stackoverflow.com/a/39461324/5032541
If you want to change git configuration to remove auto conversion, take a look on official documentation. But it's a bad idea.
The main problem imo is checking in the wrong file endings into git.
An easy way to fix all shell scripts at once is:
find . -type f -name "*.sh" -exec dos2unix {} \;
It will recursively find all files with the .sh extension and perform dos2unix on it.
I would recommend setting your git repo to checkout linux style rather than windows line endings.
I do a lot of node/docker/linux work but have a windows 10 laptop, this is what I have done.
git config --global core.autocrlf input
See this link for some more details. This way you dont need to continuously run scripts to make sure you have the correct line endings. Also a good thing to do is set you editor to default to linux line endings.

Issues with basic commands in gitbash

I'm just getting started trying to use command line and gitbash, and I've run into some basic issues.
As I understand it from the lesson I'm trying to go through online, I can run gitbash on windows instead of standard command line I would find on Mac and Linux(?)
The blurb about it was:
"WINDOWS USERS: You might want to jump ahead to the Installations Assignment and use the "Git Bash" application you'll install there instead of using the default Command Prompt. That way you can be sure all the commands will be the same."
So I downloaded Gitbash via Railsinstaller but the first command, man/man ls, gives me this error.
Am I misunderstanding the function of Gitbash? Do I need to install something to add on or something else entirely?
Unfortunately, one of the notable faults of Git Bash is that it does not ship with a man command, so no, you are not misunderstanding anything. If you try to ls or cd or grep you'll see that it works fine.
Without going into too much background, Git Bash is a shell environment on Windows that emulates standard POSIX terminal behavior and makes some common Linux tools available. I'm not personally prone to the reasoning behind this decision, but I just double-checked and man (and man-db, etc.) are available in the ecosystem behind the tool that Git Bash derives from. If you want to fight for it, you might want to open an issue on the Git for Windows GH repository; Johannes Schindelin is the lead maintainer there and is very active.

How to make optional tools of Git For Windows 2.7 load customized configuration?

I installed Git For Windows 2.7.2 a few days ago. Now I have some problems with using optional tools Git For Windows provides from cmd.exe. In the previous version of Git For Windows(or say msysgit), I could configure these tools by modifying Git/etc/git-completion.bash. For example:
alias ls='ls --show-control-chars --color=auto'
I used this way to make ls display file names that contained Chinese characters normally. Now it seems this way doesn't work. In fact there is no git-completion.bash under Git/etc/. There is a git-completion.bash under the folder Git/mingw64/share/git/completion. I tried to copy it to Git/etc and add the alias above, which didn't work either. These tools only works fine in Git Bash. So how should I configure these tools together with git to use them from cmd.exe?
This answer explains why you no longer have this functionality. In short, msysgit provided a unix shell emulator, mingw. Git for Windows is git compiled in a Windows environment.
Therefore, ls is simply an alias for dir in a Windows shell, not mingw's ls. If you want to create some Windows aliases, you can use doskey. Here's an answer for that.
Alternatively, I would suggest that you just start using PowerShell, where you'll be able to set up the $profile variable with some powerful commands like these.

What is the function of git bash for windows?

Is git bash something that can be used as a windows alternative to terminal on ubuntu? Can we use cmd.exe for the same purpose?
Git bash exists as a minimal environment for running git on Windows. Git itself consists of a number of shell and Perl scripts as well as binaries. In order to run them you need an environment that can interpret shell scripts. A Windows command prompt can only interpret Batch files.
Note that git bash doesn't have much more than the shell, git, ls, and a few other utilities. If you need a more complete shell and tool suite then look at https://www.cygwin.com/ instead.
Git BASH provides a BASH emulation used to run Git from the command line. Unix users should feel right at home, as the BASH emulation behaves just like the "git" command in LINUX and UNIX environments.
Also it is used to run commands of Linux such as ls,cd etc. If you want to use commands in Windows go install GIT BASH.
You cannot use command prompt for same purpose.

How to enable command line for Git

I've just started with Git, and I can't figure out how to enable command line for Git. I see many posts suggesting the use of msysgit to enable the Git command line, and I also see many other tools that can work around it. But currently I just get the Git client tools for Windows from GitHub. Then I can use the git command in my windows command console. I don't know if it includes the msysgit in it.
The git client tools will include msysgit. You might need to add the git bin directory into your path for ssh to work correctly with cmd (and powershell)
Also, I would highly recommend "posh git" which is a powershell module that gives you some tab completion and a git prompt in powershell, if you are a windows person, its likely you are more comfortable scripting in PS than in bash, and posh git is great for that.
find instructions here on how to install it.
Note on Windows usage: you should use Git with the provided msysGit
shell (Unix style), it allows to use the complex lines of command
given in this book. If you need, for some reason, to use the native
Windows shell / command line console, you have to use double quotes
instead of simple quotes (for parameters with spaces in them) and you
must quote the parameters ending with the circumflex accent (^) if
they are last on the line, as it is a continuation symbol in Windows.
http://git-scm.com/book/en/Getting-Started-Installing-Git
Are you using the msygit shell?

Resources