Tag: bash

How do you set default application for `open` command in terminal based on file extension type?

Some time ago I set up Sublime text 2 as my default editor for GIT in the command line terminal. I would now like to change it to LightTable, but am having some trouble. I have set both the VISUAL and EDITOR environment variables to LightTable and that does the trick for most extensions. But […]

Script to remove commits older than date specified

This question already has an answer here: How do I remove the old history from a git repository? 10 answers

Check response of git push from shell script

I’m trying to detect from bash if my git push was successful. I am checking for local changes previously in my script like this: if [ -z “$(git status –porcelain)” ]; then and that works fine. This is the expression I have tried but this one doesn’t work, in fact it errors: if [ “$(git […]

Bash script for defining flags depending on current git branch

Recently I’ve encountered a problem. I have an app that talks to the server. I want it to talk to different servers depending on what branch I’m on right now. I think the way for doing that is create a bash script which creates a .h file like #define BRANCH @”{here goes branch name}” The […]

Check if Git has changes programmatically

I want to write a script that allows me to easily change branches keeping my current changes. git stash go checkout main git stash pop The problem is if there are currently no changes in the repository. Then stash pop will pop off a previous stash. What is the easiest way to check if there […]

Git server side hook not firing – how to check

I’m trying to enforce some policies between a Git and Rational Team Concert using server side hooks. i.e. pre-receive one, but that hook seems not to be fired. Even susbsituting given rational hook with a simple bash shell that rename a file this doesn’t appear to be executed. I put the script under /hooks dir […]

GitForWindows keeps asking for OpenSSH password (Wish Application)

I just installed GitForWindows and it keeps asking me for a password even if I enter it correctly. I’ve never seen this dialog pop up before on installations on other machines (though I haven’t used Git Bash until now). How can I prevent this from popping up? I’m using ssh-agent manually anyway.

How to add color to bash output of `git diff –name-status` by file status?

I would like to style the bash output for git diff –name-status so that the files with status D, M, and A are different colors. To style general git bash I use the color options in .gitconfig. # .gitconfig [color] branch = auto diff = auto status = auto [color “branch”] current = yellow reverse […]

git pull/clone private repo using bash script only

I am new to github and bash scripting, so help will be appreciated. I want to run a script that will clone a private github repo into my instance. Since the repo is private, I understand that I need to do this through ssh. So my script starts like this: #!/bin/sh ssh-keygen -t rsa #HOW […]

Is running git update-index –refresh from PS1 prompt safe?

I’ve been researching the fastest way to check for changes in a repo to update the PS1 prompt. For reasons not worth elaborating, no access to the __git_ps1() macro, and anyway other posts have suggested various commands, including those used in __git_ps1(). Reason: I’m accessing repos on a remote server over VPN & ssh, with […]

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