5. Creating New Git Repository - rajendrapenumalli/GitNotes GitHub Wiki
- Create a new folder
- Initialise git in that repo
- Create files in that repo folder
- Add created files for tracking
- Check git status
- Check git log
- Commit changes to local repo
Usage: git init [repository name]
mkdir samplerepo
cd samplerepo
git init
raj@:~/Learning/Git/samplerepo$ git init
Initialized empty Git repository in /home/raj/Learning/Git/samplerepo/.git/
raj@:~/Learning/Git/samplerepo$ tree .git/
.git/
├── branches
├── config
├── description
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── fsmonitor-watchman.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── prepare-commit-msg.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ ├── pre-receive.sample
│ └── update.sample
├── info
│ └── exclude
├── objects
│ ├── info
│ └── pack
└── refs
├── heads
└── tags
9 directories, 15 files
raj@:~/Learning/Git/samplerepo$ echo "This a first file going to add git repo" >>readme.txt
raj@:~/Learning/Git/samplerepo$ ll
total 16
drwxr-xr-x 3 raj raj 4096 Feb 10 12:58 ./
drwxr-xr-x 3 raj raj 4096 Feb 10 12:49 ../
drwxr-xr-x 7 raj raj 4096 Feb 10 12:58 .git/
-rw-r--r-- 1 raj raj 40 Feb 10 12:58 readme.txt
raj@:~/Learning/Git/samplerepo$ git add readme.txt
raj@:~/Learning/Git/samplerepo$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: readme.txt
raj@:~/LearningContent/Git/samplerepo$ git log
fatal: your current branch 'master' does not have any commits yet
- Run git log command now
raj@:~/Learning/Git/samplerepo$ git log
fatal: your current branch 'master' does not have any commits yet
- Check .git folder now
raj@:~/Learnin/Git/samplerepo$ tree .git/
.git/
├── branches
├── config
├── description
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── fsmonitor-watchman.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── prepare-commit-msg.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ ├── pre-receive.sample
│ └── update.sample
├── index
├── info
│ └── exclude
├── objects
│ ├── 21
│ │ └── 52fd658218e534a0399309ab577fa554980ad0
│ ├── info
│ └── pack
└── refs
├── heads
└── tags
- Commit file to local repo
raj@:~/Learning/Git/samplerepo$ git commit -m "first file readme.txt commiting"
[master (root-commit) 5b88687] first file readme.txt commiting
1 file changed, 1 insertion(+)
create mode 100644 readme.txt
- Check .git folder content
raj@:~/Learning/Git/samplerepo$ tree .git/
.git/
├── branches
├── COMMIT_EDITMSG
├── config
├── description
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── fsmonitor-watchman.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── prepare-commit-msg.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ ├── pre-receive.sample
│ └── update.sample
├── index
├── info
│ └── exclude
├── logs
│ ├── HEAD
│ └── refs
│ └── heads
│ └── master
├── objects
│ ├── 21
│ │ └── 52fd658218e534a0399309ab577fa554980ad0
│ ├── 5b
│ │ └── 886877b2822679f3b8badffc6bbc36891f6f36
│ ├── c9
│ │ └── 04391a801993b923ea60a6208e20504d0f961d
│ ├── info
│ └── pack
└── refs
├── heads
│ └── master
└── tags