Git is distributed and wonderful. Svn kinda sucks. But often you still want to sort of think of your git setup as having a one central bare repository, and git does that. Steps to set-up, for your reference and mine, follow:
Go to the base root directory of your project and type:
$ git init
$ git add .
$ git commit -m "initial commit"
now your project is under git’s purview.
$ git branch
*master
and you see you have one branch named master that was auto-created by the git init and commit process above.
Now go to wherever you want the bare (central) repository to be.
$ mkdir my_repository.git
$ cd my_repository.git
$ git --bare init
Initialized empty Git repository in /home/git/my_repository.git
$ exit
Bye!
your bare repository is set-up, simple as that, but now you need to push all the files into it:
First check and see if you have any remote repositories being tracked locally:
$ cd ~/Sites/myapp
$ git remote
None came up, good.
We already looked at local branches:
$ git branch
* master
Just one branch, the master branch that is auto-created by git when you did init/commit above.
Check .git/config:
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
Now, push from your project to the bare repository:
First, let your local know about the remote (bare):
$ git remote add origin ssh://myserver.com/home/git/my_repository.git
Check your config file again ($ cat .git/config) and you will see new lines for the remote named origin.
Finally:
$ git push origin master
All set. Now you can have others pull from the bare main repository, e.g.:
$ git clone ssh://username@myserver.com/home/git/my_repository.git
SOME DRUPAL NOTES
in Drupal, you probably do not want settings.php and .htaccess included in the repository. Depending, you might also want to include sites/default/files as an ignore directory. Really, should of done this much earlier, before we added files into git. also, note: To stop tracking a file that is currently tracked, use git rm --cached filepathname
.
To ignore files, like svn propset ignore, go edit the exclude file to add in the file paths with wildcards that you wish git to ignore:
$ vim .git/info/exclude
eg.:
-bash-3.2$ cat .git/info/exclude
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
sites/default/settings.php
.htaccess
Like this:
Like Loading...