How to add exsiting project to git bare repository?
- I have created one empty bare repository on my repos server which hosted on xyz.com.
- Then in eclipse using EGit I have clone newly created bare repository.
- On my local machine I have one php project.
- Now I want to create 3 branches development, staging, production and want to add my project to development branch.
Maybe I am doing something wrong or missed something to setup. Can anyone please guide me for git setup?
All help would be appreciated.
3 Solutions collect form web for “How to add exsiting project to git bare repository?”
To create the 3 branches, you can do the following (using whatever names you prefer) from the git command line:
git checkout -b prod git checkout -b stage git checkout -b dev
To add your project to the dev branch, copy your project files into the git working directory on your filesystem – this will be the directory that contains the ‘.git’ directory (i.e. not the ‘.git’ directory itself).
Then from the command line run:
which should give you a list of the files that you copied – they will be under the heading ‘Untracked files:’.
Now run the following commands to add them to the dev branch (replacing “MyCommitMessage” with an appropriate commit message):
git add . git commit -m "MyCommitMessage"
At this point you can use
git push --all
to synchronise the remote bare repository with what you have locally.
Since you have cloned from the hosted repository, you should have a git ‘remote’ configured called ‘origin’, which refers to your hosted repository.
When you work and commit on a local branch (e.g. master) you can push that to a branch on the other repository with `git push origin :’
git push origin master:development
This assuming you have a git command line client available. You should be able to do the same thing with your graphical client, the main concept is that you push a branch with a certain name to a branch with a certain name on the other side.
I’m not sure how comfortable you are with git command line, but since it’s how I use it, here it goes:
instead of cloning your remote repo, go to your code folder and create a new local repo
commit something to your local master branch to proper init it
echo "first commit" > README.txt
git add README.txt
git commit -m "first commit"
now you can create your three branchs
git branch development
git branch staging
git branch production
change to the development branch, and add all your code
git checkout development
git add .
git commit -m "code commit"
for last, add your remote repository and push your branchs
git remote add origin <url_to_your_remote_repo>
git push -u origin --all