Typically I needed to push to a local repository when the remote one in our office was temporarily unavailable.
Suppose you have got a project called My_Project and use Git for source code management. If you would like ti set up a repository on your local machine to push to it, this guide can be useful to you.
Suppose you have got a project called My_Project and use Git for source code management. If you would like ti set up a repository on your local machine to push to it, this guide can be useful to you.
Let's start.
- Go to the directory with your project.
- Init a repository in this directory using git init
- After changing some files, commit them using git add -A and git commit -m "Initial commit"
- Create a directory called My_Repo.git on your local machine. It will be your local repository. Let's create it in the home directory.
- Go to My_Repo.git.
- Run git init --bare
- Go back to the My_Project
- Add the full path of My_Repo.git to a list of repositories of your project.
git remote add local /home/maksim-dmitriev/My_Repo.git
You are ready to push to your local repository.
git push local master
And then push, clone, and pull as usual.