Cloude Devops Logo Free Clss Will start on Devops from July 15th
Cloud DevOps
Cloud DevOps

Git init

DevOps Tutorial

git init command

A Git repository is a virtual storage place for your project that allows you to save versions of your code so that you can access them when needed.

The git init command is used to initialize a new git repository or reinitialize an existing one.

The git init command transforms the current directory into a Git repository, i.e., a .git directory with subdirectories for objects, refs/heads, refs/tags, and template files. It will also create a new master branch.

Running git init in an existing repository is safe, meaning that it will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added templates (or to move the repository to another place if the --separate-git-dir option is specified).

Example

To create a folder called myproject and transform it into a Git repository, we would need to execute the following commands:

mkdir myproject
cd myproject
git init

To create a file, run the cat or touch command, as follows:

touch code.txt

Then, add files to the repository using the git add command, as follows:

git add code.txt
git status
Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/Cloud-DevOps (master)
$ cd ..

DevOps Tutorial
Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects $ ll total 0 drwxr-xr-x 1 Cloud DevOps 197121 0 Jul 31 09:16 Cloud-DevOps/ Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects $ mkdir demo_repo Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects $ ll total 0 drwxr-xr-x 1 Cloud DevOps 197121 0 Jul 31 09:16 Cloud-DevOps/ drwxr-xr-x 1 Cloud DevOps 197121 0 Aug 1 23:02 demo_repo/ Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects $ cd demo_repo/ Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo $ git init Initialized empty Git repository in D:/Git Projects/demo_repo/.git/ DevOps Tutorial
Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ ll total 0 Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ ls Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ ls -a ./ ../ .git/ Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ ll -a total 4 drwxr-xr-x 1 Cloud DevOps 197121 0 Aug 1 23:02 ./ drwxr-xr-x 1 Cloud DevOps 197121 0 Aug 1 23:02 ../ drwxr-xr-x 1 Cloud DevOps 197121 0 Aug 1 23:02 .git/ DevOps Tutorial
Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ ll total 0 DevOps Tutorial
Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ touch devops git aws docker ansible Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ git status On branch master No commits yet Untracked files: (use "git add file..." to include in what will be committed) ansible aws devops docker git nothing added to commit but untracked files present (use "git add" to track) DevOps Tutorial
Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ git add . Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master) $ git status On branch master No commits yet Changes to be committed: (use "git rm --cached file..." to unstage) new file: ansible new file: aws new file: devops new file: docker new file: git Cloud DevOps@DESKTOP-T1B0O13 MINGW64 /d/Git Projects/demo_repo (master)











The DevOps seminar will help you to learn DevOps from scracth to deep knowledge of various DevOps tools such as fallowing List.

Linux, Git, Jenkins, Maven, Apache Tomcat, Nexus, Ansible, Chef, MySQL Docker, Nagios,   Kubernetes.
Continue to Next

Automation