Tag: bash

How to git clone dotfiles into my home directory with one command?

When you do a typical “git clone https://github.com/foo/bar.git” you get a folder in the current directory with all the files found in that directory. What I’m looking for is an optional command line arg that lets you drop all the files from that git repo (including the .git itself) in the directory you issue the […]

bash file returns unexpected token `$'do\r''

I found this script online and tried to use it: #!/bin/sh # Target directory TARGET=$3 echo “Copying to $TARGET” for i in $(git diff –name-only $1 $2) do # First create the target directory, if it doesn’t exist. mkdir -p “$TARGET/$(dirname $i)” # Then copy over the file. cp “$i” “$TARGET/$i” done echo “Done”; I’ve […]

In Git how can I stage a file I have just diffed without manually specifying the file?

I frequently diff a file, decide it’s what I’ll stage and then have to run the git add /long/path/to/file to manually specify the file. A usual work flow would go along the lines of: git status “oooh changes” git diff /long/path/to/changed/file “Yup, I remember that – commit time!” git add /long/path/to/changed/file Obviously this isn’t the […]

What is the difference between –parameter and -parameter?

I used git for some time now, but mostly I preferred the integration with Intelij IDEA. Now, in order to extend my knowledge and understanding of the system I decided to use the command line more. What I observed is that there are two types of parameters: –parameter and -parameter for example: git commit –amend […]

Bash shell script error sh: '

Aim: I’m trying to create a useful shortcut for initializing a git repo locally, and simultaneously creating a remote repo origin on bitbucket or github. This function is added to my .bashrc file in my home directory. Here is the bash function (which yields an error): function initg() { # Defaults to bitbucket API local […]

Truly Portable Git

I’m trying to create a fully portable version of git on a USB drive with it’s own SSH keys and I want it to work regardless of the drive letter windows gives it. I’ve installed portable git and most of it works. The problem I have is setting the $HOME to be dynamic I want […]

Tracking work hours through git

I recently finished a project that involved me working variable hours in one sitting. For example, I might start at 8AM and go till 2:30 PM. I would make a commit as soon as I started, and commit right before I left. I want to approximate how many hours I have worked on this project. […]

How to set TERM environment variable in Windows so that it works with Bash via SSH and locally with Git?

Background: When using my Windows version of git in Powershell I found that I got the error “terminal is not fully functional” so I used the second solution posted here (i.e. change TERM to msys) to fix the problem. However, this caused a secondary problem that when SSH’d into my Vagrant box, command line apps […]

Aliasing github.token in ~/.gitconfig to a shell command

I would like to set the value of github.token in my ~/.gitconfig to be the result of a shell command. I currently have the following: [github] user = zmanji token = !echo ~/.githubtoken 2> /dev/null However git config github.token does not return the contents of the ~/.githubtoken file but the command itself. How can I […]

Git for Windows doesn't know %USERPROFILE%

I have the same issue like Git for Windows doesn't execute my .bashrc file and tried to make the same steps. But my Git Bash (2.5.0, 64bit on Windows 7, 64bit) doesn’t know my %USERPROFILE%. pitgrap@xxx MINGW64 / $ pwd / pitgrap@xxx MINGW64 / $ cd ~ bash: cd: /%USERPROFILE%: No such file or directory […]

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