At least for someone like me where I’m the only person working on projects, the setup and usage of RCS and git are pretty straightforward. Once we get into team usage, it gets to be a bit more complicated. Right now the team can check out and check in a script but due to permissions, they aren’t able to sync the repositories. Fortunately the scripts do that every minute (checking for the flag file) but it’s a bit cumbersome.
Setup ssh git
There are a few bits that need to be done in order to get git set up.
1. Create the git user on the git server. Make sure you have sufficient space for all the code. I created a 30 gig slice in /opt/git and used it for git’s home directory.
useradd -c 'Git Service Account' -d /opt/git -m git passwd git
2. You’ll need to add your public keys into git’s .ssh directory as ‘authorized_keys’. Do this for every server you will be pulling files from.
3. Create the Master repository on the git server. You won’t need to put any code into the directory but you do need to run ‘git init –base’ to initialize it.
mkdir /opt/projects for i in suite inventory status httpd kubernetes changelog admin newuser do mkdir /opt/projects/$i cd /opt/projects/$i git init --base done
The “–base” option indicates this is a master repository, not a user’s working directory. The working directory will be on your home system.
4. On your home system, create the local or working repository.
mkdir projects cd projects
5. If you’re creating the first repository as I would for the ‘suite’ scripts, make the ‘suite’ directory and initialize it. You’ll want to set a couple of variables as well.
mkdir suite cd suite git init git config --global user.name 'Carl Schelin' git config --global user.email email@example.com
6. Since I’m converting existing RCS files, I want to bring all the previous changes into git. I’m using rcs-fast-export, a Ruby script that imports all the RCS changes into git. You’ll want to run the script in the directory.
rcs-fast-export.rb . | git fast-import && git reset
Note – this script isn’t working for the inventory application. I suspect it’s because I have three places where the same file name is used but for different purposes. Do some testing before you commit the updates.
7. Once done, push the code up to the git server. This will depend on what you have set up to manage repositories.
git push firstname.lastname@example.org:projects/suite
And you’re done. The project is ready for the team to retrieve and manage.
1. Very similar to above, each member of the team will need to copy their ssh keys over to the git server. Concatenate it with git’s authorized_keys file.
2. Create a projects directory. Don’t forget to set your git environment variables.
mkdir projects cd projects git config --global user.name 'Carl Schelin' git config --global user.email email@example.com
And you’re ready to edit code.
1. Before you can do anything, you’ll need to retrieve the git project. For the first time, you’ll have to use the clone options.
git clone firstname.lastname@example.org/projects/suite
This will retrieve all the files associated with the project you want to manage.
2. For subsequent updates, you’ll want to pull files from the server.
git pull email@example.com/projects/suite
3. You’ll now have a ‘suite’ directory. Within that are a ‘bin’ and ‘etc’ directory. Files in these directories are managed by git. As you know from RCS, you need to check out and check in changes. Use the ‘checkout’ keyword to begin editing the files. Change to the ‘bin’ directory and check out the ‘chkserver’ script.
cd suite/bin git checkout chkserver
4. You can now edit the file. Once done, you’ll need to check it back in. It’s a two step process. You need to ‘add’ it back in and then ‘commit’ the change.
git add chkserver git commit chkserver
Your editor of choice will display the current ‘git status’ as comments. Anything that’s not a comment will be added to the gitlog.
5. Once done, you’ll need to upload changes to the master.
git push firstname.lastname@example.org:projects/suite master
List of commands that you’ll find useful. I’ll add more as I explore.
- git status – Show the status of the project
- git log – Show the commit log for the project or if you pass a file name, shows the commit log for the file.