Difference between revisions of "Git FAQs"

From Genome Analysis Wiki
Jump to navigationJump to search
(No difference)

Revision as of 14:49, 9 September 2011

Turn an already existing directory into a Git Repository

Its easy to turn an already existing directory into its own repository.

  1. cd into your directory.
  2. Tell git to create a repository:
    • git init
  3. Add all your files to the repository:
    • git add .
  4. Check that you didn't add any undesired files:
    • git status
  5. Remove any undesired files (if necessary):
    • git reset HEAD filename1 filename2
  6. Commit the files:
    • git commit -m Initialize the repository with all the files


Continue to the next section if you want to create a bare repository for it to push to/pull from.

Create a remote bare Git repository for a repository to push to/pull from

  1. cd to where you want the remote repository located.
  2. Create the bare repository.
    • git init --bare --shared bareRepoName
  3. cd to your repository that you want link to this bare repository.
  4. Set the remote.
    • git remote add origin path to/url for your bare repository
  5. Set the configuration for pulling.
    • git config branch.master.remote origin
    • git config branch.master.merge refs/heads/master
  6. Push your files to the bare repository (must specify origin master since this is the first push to the empty repository)
    • git push origin master

You can now operate as if you had cloned from bareRepoName.