Tag: bash

Get git commands list

I would like to make an alias for every git command. As there are many of them, I would like to get them on a list to then make a loop in my .bashrc. Is there any way to get them in shell script?

$PATH extended at .bashrc not available within git hook script

I need to run a certain command when a push is received in a repository. That binary is located at a custom path which I added to .bashrc and works normally from the shell. I wrote a little script as a git hook. However, the .bashrc additions don’t seem to affect this script. I’ve tried […]

How to pragmatically check with bash script if a branch in git needs to be rebased?

I’m working on a bash script for my team to enforce regular rebasing of working branches. The problem I am facing at the moment is how to determine whether a branch is behind master and/or if it needs to be rebased, rather than blindly attempting to rebase the branch. Here is a simplified version of […]

Is there a way to force the creation of a remote repository?

I’m jus trying to clean up my code and eliminate errors. If I run: git remote add godaddy $user1@foo.com:~/root.git I get fatal: remote godaddy already exists. I know it exists, but I just want it to ignore it and create it again. For example you can suppress errors for mkdir with the -p I checked […]

Find total size of uncommited or untracked files in git

I have a big horrible pile of code and I am setting it up in version control. I would like a command I can run on Linux to give me the total size of the files that would be commited and pushed if I ran git add -A && git commit -am ‘initial commit’ The […]

Add items to git index efficiently

I find it very tedious to write full paths when adding changed files to index. For example, i’ve changed 3 files, but want to commit only 2 of them: # Changed but not updated: # (use “git add <file>…” to update what will be committed) # (use “git checkout — <file>…” to discard changes in […]

Branch autocompletion does not work with git alias for push

I am using Git with git-completion and everything works fine with a single exception: when I do git p some_remote [TAB] I get as autocomplete suggestions the files in the current directory (wrong). p is a Git alias: $ cat ~/.gitconfig [alias] p = push Still, when I do: git push some_remote [TAB] I get […]

Don't want to use double quotes when using git commit -a -m

I’m a bit tired of using double quotation marks, when I use git commit git commit -a -m “fix xxx error” when I set alias like this: coam = “!f() { git commit -a -m $1; }; f” It works when I type git coam fix it commit as git commit -a -m “fix” but […]

Starting a SourceTree git project from scratch

It’s really unfortunate that there are no complete SourceTree tutorials out there. I’m trying to create a really simple git project to learn my way around git and SourceTree. So here’s what I did: I created a new folder and started an html page in it. In the Git Bash, I navigated to the directory […]

How to “-@-expand (”${array}”) possibly empty array in Bash when nounset is set?

I have bash script with set -o nounset option (and I want that!). Now, I want construct a command invocation, but I don’t know number of arguments beforehand, so I want to use an array for that (example below). However, when ARRAY is an empty array, “${ARRAY[@]}” fails. Question: how to @-expand array (“${ARRAY[@]}”) so […]

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