How to create a local GIT server for an existing project
This post will describe how to create a local Git server based on a existing project in a secure way, meaning that you will not have any risk to lose information, unless you delete something by your own.
1. Create a home directory for your Git server.
This is a folder that will contain your versioned projects on Git. After you have everything set, you will connect here and clone your local copies and push changes you made. This will be your local Git server.
2. Inside your Git server directory, initilize a Git repository for your existing project. This command creates an empty dir, where you will push your existing project´s code.
3. Copy your working project to some tmp dir anywhere:
4. Go to the copied dir and initialize it as a Git repository. You can do it in the original one with any risk. This copy is just for your confort.
5. Now you have your Git server folder and your original project folder as a Git repository. All you need to do is to connect both and push the initial data to the server.
Go to your copied project dir and set the address of the Git Server.
6. At last, push data from your existing project copied dir to the Git local server:
To check if everything is right, make a clone of the server:
Now you may have a working clone of your project. Make how many clones your team needs.
1. Create a home directory for your Git server.
This is a folder that will contain your versioned projects on Git. After you have everything set, you will connect here and clone your local copies and push changes you made. This will be your local Git server.
- mkdir </home/git_server/>
2. Inside your Git server directory, initilize a Git repository for your existing project. This command creates an empty dir, where you will push your existing project´s code.
- cd </home/git_server/>
- git init --bare <any_project_name.git>
- </home/git_server/any_project_name.git>
3. Copy your working project to some tmp dir anywhere:
- cp -r <your_project_dir> <copy_of_your_project>
4. Go to the copied dir and initialize it as a Git repository. You can do it in the original one with any risk. This copy is just for your confort.
- cd <copy_of_your_project>
- git init
5. Now you have your Git server folder and your original project folder as a Git repository. All you need to do is to connect both and push the initial data to the server.
Go to your copied project dir and set the address of the Git Server.
- cd <copy_of_your_project>
- git remote add origin </home/git_server/any_project_name.git>
6. At last, push data from your existing project copied dir to the Git local server:
- git add .
- git commit -m 'initial commit'
- git push origin master
To check if everything is right, make a clone of the server:
- cd <anywhere>
- git clone </home/git_server/any_project_name.git>
Now you may have a working clone of your project. Make how many clones your team needs.