长平狐 发布于 2013/03/04 19:30
阅读 110
收藏 0



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://
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:

  1. Navigate to your repository
    1. 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.
  2. Create a new directory with the name you want for the repository, eg mkdir DIRNAME .
  3. 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.