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

Monday, March 26, 2012

git: Rename the Directory Containing a Repository

When we thought about doing this it seemed like it was going to be a big deal but it turned out to be pretty simple. The following steps accomplished what was necessary:

1. Modify gitosis.conf to add the new directory

[group foo]
writable = foo
members = @developers

[group foo_readonly]
readonly = foo
members = @designers @developers

[group bar]
writable = bar
members = @developers

[group bar_readonly]
readonly = bar
members = @designers @developers

2. mv oldDir newDir

On origin, run the bash 'mv' command
mv foo bar

3. Work with new code

On my development machine, run git clone on the new directory and start working with the files. In our case we were using the old directory name for a new project. Running git pull from my development machine created an empty git repository on origin with the old directory name.

Thursday, March 31, 2011

Using git to add a submodule

The command to add a submodule to a project is:
git submodule add <URL of the submodule repo> <path to place submodule> 
Example:
git submodule add git@1.1.1.1:Submodule.git ./Submodule 
This will modify the .gitmodules file in the repository. When I ran this command, I got a fatal message stating:
fatal: LF would be replaced by CRLF in .gitmodules
Failed to register submodule 'Submodule' 
Modifying the .gitmodules file manually by replacing the LF with a CRLF fixed this problem (ie. open the file in Notepad++ or another text editor, delete the end of line character, and hit 'Enter' on the keyboard for each of the new lines added for this submodule).

Running the command
git submodule status
will show that this submodule isn't ready to be used as of yet. Run
git submodule init
to initialize this submodule. You should not need to run update for this submodule because the clone happened when the submodule was added.

Add, commit, and push this file so that other users will be able to have the changes.