First Repository
(this is a walk-through, so prepare your computer and let's play around with git) (this post if part of the material I cover in my devops course)
Saving Versions in git
- This is the main thing in a version control system, isn't it?
- Let's say you have a project, so several files
Installing git
- Git is basically a cli program, and the installation should not be too hard.
- Go to the installation page and find how to install git on your system
- I'm using Ubuntu, so for me:
1sudo apt install git-all
should work.
- Make sure it is working:
1$> git --version
2git version 2.39.2
3$>
First Repository
- A git repository is where git is going to keep those snapshots, the history of the project.
- I'll create a new directory, and create a git repository in it:
1$>
2$> mkdir my-project
3$> cd my-project/
4$>
5$> git init
6hint: Using 'master' as the name for the initial branch. This default branch name
7hint: is subject to change. To configure the initial branch name to use in all
8...
9...
10hint:
11hint: git branch -m <name>
12Initialized empty Git repository in /home/osboxes/my-project/.git/
13$>
14$> ls -la
15total 12
16drwxrwxr-x 3 osboxes osboxes 4096 Jan 22 11:24 .
17drwxr-x--- 32 osboxes osboxes 4096 Jan 22 11:24 ..
18drwxrwxr-x 7 osboxes osboxes 4096 Jan 22 11:24 .git
19$>
- As you can see, git is giving me many hints about my new repository, but the end line confirms that the repository was created.
- Indeed, the repository is kept inside the invisible .git subdirectory
- The directory I have created (my-project in this example) is called the working directory in git jargon.
- We can see what's going on in out project by using the git status command.
- Note that the documentation still uses the old git-status form (called the dash form).
This is kept for historical reasons:
1>
2$> git status
3On branch master
4
5No commits yet
6
7nothing to commit (create/copy files and use "git add" to track)
8$>
- So there is nothing is the repository (yet)