Tag: bash

How to write a shell script that checks if git repository is up to date?

#!/bin/bash #gedit tidy plugin init=false SRC_DIR=~/repos DIRECTORY=”Gedit-Clientside-Plugin” #making repos directory if [ ! -d “$SRC_DIR” ]; then mkdir $SRC_DIR; fi if [ ! -d “$SRC_DIR/$DIRECTORY” ]; then init=true cd $SRC_DIR && pwd && git clone git://github.com/trentrichardson/Gedit-Clientside-Plugin.git && cd $DIRECTORY else cd $SRC_DIR/$DIRECTORY fi #below here is what I’m having trouble with git pull 1>&1 | […]

Adding git alias to .bash_profile not working

I edited my $Home .bash_profile to include some git alias commands. I am rather new to this and I can’t figure out what went wrong. .bash_profile alias gs=’git status ‘ alias ga=’git add ‘ alias gb=’git branch ‘ alias gc=’git commit’ alias gd=’git diff’ alias go=’git checkout ‘ alias gk=’gitk –all&’ alias gx=’gitx –all’ alias […]

Git – How to find all “unpushed” commits for all projects in a directory?

I’m finally getting used to Git and, after the initial steep learning curve, I must say it’s quite good (I just miss the single file externals, but that’s another story). I have, however, an issue that I can’t solve: I’m currently working on a dozen projects at the same time. They are all interconnected and […]

git bash fail to push branch with error message: “object directory does not exist”

recently I’ve updated my Git Bash to the latest version and now when I’m trying to push a branch to the remote server I get an error message: $ git push –set-upstream origin bugs/purlin_support_reactions Counting objects: 41, done. Delta compression using up to 4 threads. Compressing objects: 100% (41/41), done. Writing objects: 100% (41/41), 4.91 […]

Git Bash: Launch Application via Alias without hanging Bash (WIndows)

I’ve created several bash aliases in Git Bash on Windows, to launch executables from the bash shell. The problem I am having is that is seems the bash is waiting for an exit code before it starts responding to input again, as once I close the app it launched, it starts taking commands again. Is […]

How to use git hook pre-commit to stop commits to master

I want to stop myself accidently commiting something to the master branch unless I am sure. So I tried this script to determine which branch I am on but there is a problem. When I create a new branch git name-rev returns master even though I am on the other branch $ git branch ignore […]

pipe is returning empty string in bash in git for windows

Edit: Issue has been resolved after update to Git for Windows >= 2.9.0.windows1 Disclaimer Some comments are referring to full “story” behind this issue but I decided to shorten it because it was getting too long and hard to follow. I present you as succinct failing example as possible. For those who are interested in […]

Fastest way to get git status in bash

For a while now I’ve been using the __git_ps1 function in my bash‘s PS1 prompt (with PS1=’\w$(__git_ps1)’). Now I want to color it depending on branch status. I wrote a bash function that checks if the current branch is modified, and colors red or white depending on the status. The problem is that it uses […]

Running .sh scripts in Git bash

I’m on a Windows machine using git 2.7.2.windows.1 with MINGW64. I have a script in C:/path/to/scripts/myScript.sh How do I execute this script from my git bash? It was possible to add it to the .bashrc file and then just execute the entire bashrc file. But I want to add the script to a separate file […]

Run git gc on multiple repositories

I have a git repository root at /git There are different depth of paths, such as: /git/project/project1/module1.git /git/project/project1/module2.git /git/project/project2/dev/module1.git /git/library/libgit2.git /git/library/jquery/jquery.git How to I run git gc recursively in all repos inside /git? I would prefer to use a shell script to iterate over the repositories: If that directory is not a valid git repository, […]

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