Don’t play with IFS when you play with git
IFS is the ‘intrafield separator’ bash and others use to figure out what a separate argument is - normally it contains at least a space, a tab and a return character. Most applications are immune to changes to this variable so when dealing with a list of files containing spaces it can be cool to reset IFS to a return character only:
godot@eco:~/tmp$ echo “hello” > bla\ bla
godot@eco:~/tmp$ echo “there” > bla\ bli
godot@eco:~/tmp$ for dada in $(ls); do cat $dada; done
cat: bla: No such file or directory
cat: bla: No such file or directory
cat: bla: No such file or directory
cat: bli: No such file or directory
godot@eco:~/tmp$ export IFS=”
> “
godot@eco:~/tmp$ for dada in $(ls); do cat $dada; done
hello
there
Now after all this, some work with loops, convert, imagemagick and some lunch I came back to the same shell and wanted to clone a repository:
godot@eco:~/git$ git clone git@github.com:simplificator/uptimehq.gitInitialized empty Git repository in /home/godot/git/uptimehq/.git/
remote: Counting objects: 4253, done.
remote: Compressing objects: 100% (2658/2658), done.
remote: Total 4253 (delta 1289), reused 4253 (delta 1289)
Receiving objects: 100% (4253/4253), 3.71 MiB | 138 KiB/s, done.
Resolving deltas: 100% (1289/1289), done.
cd: 518: can’t cd to /home/godot/git/uptimehq/.git/refs/remotes/origin
Warning: Remote HEAD refers to nonexistent ref, unable to checkout.
Trying to pull manually gives:
godot@eco:~/git/uptimehq$ git pull origin master
fatal: b3392429416c77e1242c5307f160b51b75c57057 : not a valid SHA1
In the deep confusion which followed I got more very telling errors which I would like to post here.
godot@eco:~/git/uptimehq$ git merge origin/master
fatal: Not a valid object name 897a76b11443dfa7f3ba37a39dcb9831a47d445a
fatal: Could not resolve ref ‘897a76b11443dfa7f3ba37a39dcb9831a47d445a ‘
Merge with strategy recursive failed.
godot@eco:~/git/uptimehq$ git rebase origin/master
Current branch master is up to date.
godot@eco:~/git/uptimehq$ git pull
897a76b11443dfa7f3ba37a39dcb9831a47d445a - not something we can merge
So whenever you get here - check your shells IFS. Or get a new shell.
