步骤如下,摘自sourceforge的帮助文档,但是要注意的一点是,在创建本地仓库之后,需要做一
次提交,才能执行其他的步骤。原因大概是因为没有做commit的话,本地仓库没有master这个分支。
How to push a local repository
Before you push your files, you need a local Git repository. You can either create one from scratch, convert a repository (e.g. via git-cvsimport or similar), or start with a copy of an existing Git repository.
For any local Git repository, you can configure it to push data back to our server by doing the following from inside your Git repository (this replicates what a "git clone " from our servers sets up for you automatically):
git remote add origin ssh://USERNAME@PROJECTNAME.git.sourceforge.net/gitroot/PROJECTNAME/REPONAME
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
Now you're ready to push the committed files to our servers:
git push origin master
Note: The use of "origin master" prevents Git from complaining that the remote server has no branches in common with your local repository (which is true at the start when the remote repository is completely empty), and "master" is the default branch in Git.
After the first push, you will be able to use the simpler "git push " to push the master branch to our "origin" server.
Once that is done, you will be able to browse your newly-committed content via gitweb, clone the repository via either read-only or read/write access methods, push more check-ins, etc.
Creating Multiple Repositories
To create a new repository, you need to access the Shell service , then follow these steps:
- Navigate to your repository
- cd /home/scm_git/P/PR/PROJECTUNIXNAME
- PROJECTUNIXNAME is the UNIX name of your project
- P represents the first letter of that name, and PR the first two letters of the name.
- cd /home/scm_git/P/PR/PROJECTUNIXNAME
- Create a new directory with the name you want for the repository, eg mkdir DIRNAME .
- Run git --git-dir=DIRNAME init --shared=all --bare (where DIRNAME represents the name of the repository to be created)
- This will initialize a new repository at that directory
Notes: Developers should not nest directories / repositories. Directories should only be created the top level directory of repository. Be sure to make backups prior to editing your repository contents.