-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_my_first_local_repo.txt
37 lines (31 loc) · 1.79 KB
/
create_my_first_local_repo.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
To use GIT for any project you are inteseted in, depends on where the project of interest is:
1) Local: Projects that are on your machine
For these, you initialize (create) the repo on your machine
2) Remote: Projects that already exist as a git repository online
For these, you clone (download) the online repo to your machine
Both scenarios result in a project with a repo folder (project/.git/) on your local machine that is:
- ready for development
- under version control
- tracked
To get started, we will initialize a local repo but later in remotes.txt you will learn how to clone a repo
#############################
# Initializing a local repo #
#############################
# I prefer to add the suffix '_repo' to the top folder of my project so I don't forget the project is under GIT version control
mkdir projectname_repo # if new directory
(or mv projectname/ projectname_repo # if existing directory)
cd projectname_repo
git init # creates .git folder
git status -v # view status of the repo & check default branch name i.e (all new repos should be main, not master)
If default branch name is master:
git branch -m master main # change default branch name to 'main'
git config --global init.defaultBranch main # set global variable to name future new default branches to main, instead of master
######################
# Take a look inside #
######################
cd projectname_repo
du -hs .git # view .git folder disk usage
tree .git # view .git folder contents as a tree
Now notice the tree structure and files inside the .git folder, and how little storage it uses!
This is the working brain of git. It stores all the info for tracking and version control.
If you ever want to stop using GIT for this project, you just have to delete the .git folder.