Command Line
Command Line
Version Control
Let's say you are working on a web development
project with a team of developers. The project
involves creating a website for a client. Each team
member is responsible for different sections of
the website, such as the homepage, product
pages, and contact form.
geekster.in
Developer C is responsible for the contact
form and makes changes to the HTML and
PHP files.
geekster.in
Developer A works on the homepage in their
branch, Developer B on the product pages in
another branch, and Developer C on the
contact form in their own branch.
geekster.in
What is version control.
geekster.in
To master the fundamentals of the Unix
command, we will utilise git bash in this lesson.
geekster.in
Navigating directory
geekster.in
Making Directory
The command that allows you to create
directories is 'mkdir'.
geekster.in
Note: Remember that when you do not mention a
more than one-word directory name, it will create
two directories.
geekster.in
Note: It is worth noting that 'ls' won't show the
hidden folders. You need to use 'ls -a' for the
same.
geekster.in
You can create directories one by one with
'mkdir', but this can be time-consuming. To avoid
that, you can run a single mkdir command to
create multiple directories at once.
geekster.in
Detail List
geekster.in
Creating file
Its is a very simple to create file in git bash at first
write touch then file name with extension.
geekster.in
Opening and writing on file
geekster.in
As you can see from the above figure, the cursor
is active and you can write on the pad. You can
only use arrow keys to move the cursor left,
right, up, and down. Let's write some text on the
opened pad. There are instructors at the
bottom that tells how to exit. For instance ctrl +
x is to exit. When you exit either you save or
cancel which comes when you click ctrl + x.
geekster.in
Now you can save the modified file by writing Y or
you can cancel it by clicking ctrl + c.
After you write Y then click enter.
geekster.in
Copy file
The command cp followed by the name of the file
you want to copy and the name of the directory
to where you want to copy the file (e.g. cp
filename directory-name )
Let's have day1-backup.txt from day1.txt by
copying using the cp command
geekster.in
Rename file
We use the git mv command in git to rename and
move files. We only use the command for
convenience. It does not rename or move the
actual file, but rather deletes the existing file and
creates a new file with a new name or in another
folder.
geekster.in
Moving file and directory
geekster.in
geekster.in
Delete file and directory
To delete (i.e. remove) a directory and all the
sub-directories and files that it contains, navigate
to its parent directory, and then use the
command rm -r followed by the name of the
directory you want to delete (e.g. rm -r directory-
name ). Let's remove the day-one.txt file from the
Day-01 folder.
geekster.in
The rmdir delete a folder.Let's delete the day5
folder.
geekster.in
geekster.in
1. rm-r removes the file "file.txt" from the
repository's staging area, and it will be deleted
in the next commit.
2. To remove a directory (and its contents) from
the repository:
geekster.in
Git and GitHub
geekster.in
Before using Git we should know
why we need it
1. Install Git
First, you need to install the version control
software, Git.
geekster.in
2. Checking status of the repository
The git status command displays the state of the
working directory and the staging area. It lets you
see which changes have been staged, which
haven’t, and which files aren’t being tracked by
Git.
geekster.in
To set your global commit name and email
address run the git config command with the --
global option.
geekster.in
geekster.in