-
Notifications
You must be signed in to change notification settings - Fork 479
Create a Repostiory
This guide will take you through creating a git repository, adding a couple of example files, then encrypting some of the files using git-crypt.
If you already know how to create a git repository then you can skip this section
Lets assume we have the following directory \home\user\development\myProject
, we want to be able to keep our code under version control and we've chosen git. To start with we will need to turn the directory into a git repository.
$ git init
If we look in the directory now, we can see that there is a .git
directory present, this denotes the fact that we are currently in a git working tree. Assuming we have started afresh we will create a couple of files and add them to git.
$ touch README.md
We've created the file README.md
, to which we assume that some data has been added. Now we will add the file to the repository, and commit it.
$ git add README.md
$ git commit -m "Initial Commit"
Now we've got our files sitting there committed and the repository is ready to go! Now we will just quickly add a few files, some of which will be used later when we encrypt them.
$ touch myFile.txt mySecret.txt passwords.secure myKeys.secure
$ git add -A
$ git commit -m "Added some files"
We now have a working repository, although we have some secret stuff in there that we require encrypted. First we need to initialize our git repository to use git-crypt
$ git-crypt init
Now that the repository has been initialized for the use of git-crypt we will go through setting up the filters. The following shows the creation of the file in which the filters live.
$ touch .gitattributes
$ vim .gitattributes
We will put the following into the above file.
mySecret.txt filter=git-crypt diff=git-crypt
*.secure filter=git-crypt diff=git-crypt
Now we have created the filters file for git-crypt to determine which files are to be encrypted and which ones are not. We must now commit these changes.
$ git add -A
$ git commit -m "Added .gitattributes for git-crypt"
The next step is adding a GPG Key into the mix so that we're able to clone this repository else where and work on it, or have someone else work on it, whilst being able to get access to the encrypted files if it is required.
$ git-crypt add-gpg-user 1A43K92C
We have assigned the above GPG Key to have access to our encrypted files. This action automatically does a git add
and git commit
, so we don't need to worry about doing that.
Now we are ready to go, we have our repository and we've encrypted the files that we want to keep secure.