Like many of you, sometimes we develop code that does not belong to a Git
server.
Working as so, one would think that we would miss all the features of a Version Control System
(VCS
).
Fortunately, this assumption is wrong.
Using the already installed Git
tools, we can create a new local repository
in any system folder with no additional configuration.
To do so, and create a new repository from an existing project, we need to do the following using a terminal/shell:
- Navigate into the directory that contains the project e.g.
cd /home/bytefreaks/Projects/Party/banana/
- Type
git init
This command will create an emptyGit repository
in that folder and it will produce a message as follows:
Initialized empty Git repository in /home/bytefreaks/Projects/Party/banana/.git/
- In case you have files that should not be included in your repository, it is better that you create a
.gitignore
file and add them there.
This way you will be able to indicate all of the files that you don’t want to the repository to track. - Use
git add .
(please note that you need the dot.
for this command)
This command will stage all files that are not in.gitignore
to be part of your next commit. - Finally, type
git commit
orgit commit -m "Initial Commit with status bla bla"
, to make your first commit to the repository - …
- Profit!
By now, you should have a fully functional local git repository without the assistance of an external server.
This post is also available in: Αγγλικα