Tag: bash

Is it possible to pre-evaluate a value in bash's PS1?

I’m trying to build a Bash prompt which will have both my git branch information (using __git_ps1 from git’s bash-completion) and a little colored smiley to indicate whether the most recently run command was successful. The smiley is created using this technique, which I found here on SO: SMILEY=”${GREEN}:)${COLOR_NONE}” FROWNY=”${RED}:(${COLOR_NONE}” STATUS_EMOTICON=”if [ \$? = 0 […]

Bash script to extract filenames from git whatchanged

I’m trying to get a list of all the js files that changed to know what to reminify. I previously asked this question So far this is the best I came up with but it feels really unsafe. GITCHANGES=$(git whatchanged -n 1 –pretty=format:) I=0; for f in $GITCHANGES; do I=$(($I + 1)); if [[ $(($I […]

git – setting path variable

When I run the following command to change my path variable in the git bash – it works. After I’ve run a few git-tfs commands it reverts back to the original setup. Is it possible to explain why? $ PATH=$PATH:my git-tfs path goes here To clarify, it works at first. But then the git-tfs commands […]

“bash: __gitdir: command not found” error in terminal

Whenever I’m working in the command window, I get the error: “bash: __gitdir: command not found” right above the working line (in other words, right after any command, before it prompts for a new one). Any ideas as to what is going on to bring this up?

How to set the correct shebang for the needed Ruby version

I am running Ruby 2.0.0 with MacOS x. For some reason, when I run git push on my local gitlab, I have a script that begins with #! /usr/bin/env ruby The Ruby version that is processed is ruby1.8.7 which breaks the app. How can I set correctly this shebang in order to use Ruby 2.0.0?

In git, how can I remove Windows line endings from changed lines only?

Sometimes when I’m trying to contribute code to an open source project, the project has not been formatted and contains both UNIX and Window line endings. My “smart” IDE will somehow detect which type of ending to use for each file, and if it detects Windows line endings, then all my changes will have Windows […]

linux PS1 – display branch name only inside a git repo

After searching the net, I found that one can display the git branch name with the PS1 with below PS1=”$(__git_ps1 ) ” While this is working fine, and it display the branch name in PS1 prompt. But it is displayed where-ever I navigate, even outside the git-checked-out-repo. I would like to display the branch name […]

Disable -m in git

I am trying to train myself to write better commit messages, so I have created an entry in my ~/.gitconfig [commit] template = ~/.gitmessage.txt The conundrum is that I nearly always use: git commit -m “Message here” and sometimes: git commit -am “Message here” How can I prevent myself from using the -m flag, so […]

Git: Getting total numbers of uncomitted lines in a repo

Is there a command to get just total number of lines that are changed in current git repo. I want to take count considering both staged and unstaged files. This is the closest I could get $ git diff –cached –shortstat 1 file changed, 1 insertion(+), 1 deletion(-) $ git diff –shortstat 1 file changed, […]

unable to look up https fatal error when push to git repository

in git bash, I got a fatal error when try to push to a remote repository. fatal:unable to look up https (port <none>) (here with some unrecognized character %#^%) in git shell, besides the fatal error I listed above, it occurs another warning waring: Your console font probably doesn’t support unicoode. if you experience strange […]

Git Baby is a git and github fan, let's start git clone.