Like many of you, sometimes we develop code that does not belong to a
Working as so, one would think that we would miss all the features of a
Version Control System (
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.
This command will create an empty
Git repositoryin 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
.gitignorefile 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.
git add .(please note that you need the dot
.for this command)
This command will stage all files that are not in
.gitignoreto be part of your next commit.
- Finally, type
git commit -m "Initial Commit with status bla bla", to make your first commit to the repository
By now, you should have a fully functional local git repository without the assistance of an external server.
This post is also available in: Greek