Git Getting started for absolute beginners

M H
2 min readOct 22, 2021
@synkevych — unsplash.com

Download Git Bash from here. https://git-scm.com/downloads

Step 0:

After downloading and Installing Git bash. Create a new folder, right-click on it and click on Git Bash Here.

Copied all your files in it or you can add this folder to VS Code or whatever to start creating project files.

Initialize the repository.

git init

Step 2:

Add all files in the staging area.

git add .

Step 3:

Commit the changes in the local repository.

git commit -m "message fo this commit"

Step 4:

Add code to the remote repository.

Step 4.1

Go to Github.com or Gitlab.com and create a new repository.

copy the link

Step 4.2:

For the First time, You have to Add the below command in bash to link the remote with the local repo.

git remote add name <your-url>git remote add origin https://github.com/yourUsername/repository-name.git

You can replace the name with any name you want for your remote repo. By convention we use origin.

Step 4.3:

push to remote.

git push -u origin master

A popup appears, enter your username and your account password. Write you GitHub credentials and done :)

How to Clone someone else's repository in your local machine.

Step 1:

Create a folder named "whatever you want".

Step 2:

Initialize the repository

git init

Step 3:

Copy the link of the repository you want to clone from Github.com or Gitlab.com.

Step 4:

Write this command.

git clone <https://github.com/link_you_copied.git>

Additional:

Log of your recent commit.

git log

If you want to ignore some files, prevent them to add to the git repository.

For this, you have to create a .gitignore file.

touch .gitignore

open your editor/IDE, open the .gitignore file, and simply add the name of files with their extension that you want to be ignored.

filename.extention
/directoryname

You can also add directories in .gitignore. By using “/”.

reset local repository:

git reset --hard origin/master

Parse and shorten commit SHA tag.

git rev-parse --short HEAD

Git official Book to learn everything about git from Scratch.

https://git-scm.com/book/en/v2

--

--