Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Sunday, February 12, 2017

Git rm may cause insanity

Git rm may cause insanity


Ran across this today, and wanted to help others avoid the same fate. If you use git rm to remove the last file in a directory, it will remove the directory as well. If you are in that directory, odd things can happen that will potentially drive you insane.

Lets create a git repository with a folder that has a single file in it:
$ cd /tmp
$ mkdir foo
$ cd foo/
$ git init
Initialized empty Git repository in /private/tmp/foo/.git/
$ mkdir bar
$ cd bar/
$ echo hello > splat.txt
$ git add splat.txt
$ git ci -m adding a text file
[master (root-commit) 069f11b] adding a text file
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 bar/splat.txt

So I now have a git repository and placed the file bar/splat.txt under revision control. Now if I do:
$ git rm splat.txt
rm bar/splat.txt
This will not only remove splat.txt, but it will remove the whole bar directory. I say this will drive you insane, because if you try to move or copy a file into your current directory, youll get an error that will probably catch you off guard. Like:
$ cp ~/.gitignore .
cp: ./.gitignore: No such file or directory
There is a file called .gitignore in my home directory, its just that my current directory no longer exists. It took me about five minutes to realize what was going on... and I was starting to wonder if I knew how to use the cp command.

The reason I ran into this is that I was rearranging my .vim folder to use pathogen. I keep all of my dot files under source control and stumbled upon this while clearing out my vim autoload folder.

Available link for download

Read more »

Thursday, January 26, 2017

Git and Hudson

Git and Hudson


I just encountered a rather annoying problem when running Hudson as a service on Ubuntu. I was getting the following exception whenever the build checked code out of GitHub:
hudson.plugins.git.GitException: Could not apply tag hudson-Selenium_RC_Plugin-23
at hudson.plugins.git.GitAPI.tag(GitAPI.java:265)
It turns out Git needs a username to be set and the hudson user that the Debian package creates when Hudson is installed doesnt have one. Easily fixed by using sudo nano /etc/passwd to add Hudson,,, into the hudson users entry (if you look at your own entry you should see where it needs to go).

Available link for download

Read more »