Difference between revisions of "Git FAQs"
From Genome Analysis Wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
+ | == Turn an already existing directory into a Git Repository == | ||
+ | |||
Its easy to turn an already existing directory into its own repository. | Its easy to turn an already existing directory into its own repository. | ||
Line 14: | Line 16: | ||
− | + | 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 == | ||
+ | |||
+ | # cd to where you want the remote repository located. | ||
+ | # Create the bare repository. | ||
+ | #* <code>git init --bare --shared ''bareRepoName''</code> | ||
+ | # cd to your repository that you want link to this bare repository. | ||
+ | # Set the remote. | ||
+ | #* <code>git remote add origin ''path to/url for your bare repository''</code> | ||
+ | # Set the configuration for pulling. | ||
+ | #* <code>git config branch.master.remote origin</code> | ||
+ | #* <code>git config branch.master.merge refs/heads/master</code> | ||
+ | # Push your files to the bare repository (must specify origin master since this is the first push to the empty repository) | ||
+ | #* <code>git push origin master</code> | ||
+ | |||
+ | You can now operate as if you had cloned from bareRepoName. |
Revision as of 18:07, 14 July 2011
Turn an already existing directory into a Git Repository
Its easy to turn an already existing directory into its own repository.
- cd into your directory.
- Tell git to create a repository:
git init
- Add all your files to the repository:
git add .
- Check that you didn't add any undesired files:
git status
- Remove any undesired files (if necessary):
git reset HEAD filename1 filename2
- 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
- cd to where you want the remote repository located.
- Create the bare repository.
git init --bare --shared bareRepoName
- cd to your repository that you want link to this bare repository.
- Set the remote.
git remote add origin path to/url for your bare repository
- Set the configuration for pulling.
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
- 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.