Usage of Basic Git commands and Github

Usage of Basic Git commands and Github

Hello guys😎,

I would like to share some of basic git commands for you. This is not kind of specific documentation. I collected it for my learning process in git last year. Before you read, please note that all are written in informal style like a sketch.

Anyway, I hope it may help you to know some basic git commands and github in one place.

Let's roll 😉..

GIT

Git is a distributed version control system for tracking changes in computer files and coordinating work on those files among multiple people.

version-control-system: Version control systems are a category of software tools that help a software team manage changes to source code over time. Version control software keeps track of every modification to the code in a special kind of database.

STAGES OF GIT

there are three stages

1.working tree 2.stagging area 3.commit

  • Working tree: working tree consist of current working files in which we can add and edit files it is also called an untracked area of git if we make changes in our working file git recognized a modification

  • Staging area: this stage starts the tracking of our repo from this stage we have two options either go to commit and another one is going to working tree for modification.

  • Commit: git commit command takes a snapshot representing the staged changes

Git Basic Commands

  • git init = create new git repo
  • git status = check modify files
  • git add . = add modify files into stage
  • git commit -m "type message" = commit files with messages
  • git log = show history of commit
  • git log --oneline = show history of commit in short way

  • git checkout = switch to commit file

  • git reset --head = Delete commit file

  • git branch -a = show all branch in repo

  • git branch = create new branch in repo

  • git checkout = switch to branch

  • git checkout -b = switch and create new branch in repo

  • git branch -D = Delete existing branch before merge

  • git branch -d = Delete existing branch after merge

  • git merge = when you have to merge, first switch to the branch which is merged. Then, git merge and run it. If conflict when merge, fix in the code file and,

  • git add .
  • git commit then sound a screen, you need to press shift+; and type :wq to escape that screen. It will merge as perfect🍾.

Github [remote repository management]

GitHub is a website and cloud-based service that helps developers store and manage their code, as well as track and control changes to their code In Github, we can create a copy of a project and assigned to anyone Create Github Account Create New repository

1. How to Upload Your local Repo to Github

open your local repo directory in cmd or gitbash check if there is nothing left to commit with git status,git push

In this case, everytime you want to push, url of remote repo is too long to add. So, Let's give an alias name(short name) for url of remote repo. By this command, git remote add git push origin

2. How to clone Remote Repo to Your Local Machine

git clone

At this time, github originally add remote url alias name as origin (you don't have to change) By push, git push origin

Collaborating between Developers [pull request]

When you are in different branch and push into remote repo. Other developers and your manager exists and they review your code. In this case, your pushed code have to be a pull request. Others reviewed and comment on it. Then, everyone approve -> merge into master

Fork [contributing]

Some open soure project or some public source code are free. you can fork them into your github account. Then, clone in local repo changes files push to your github account. Create pull request to parent open-source project or source-code. Then, owner of project review and comment your changes and only owner can merge your codes into parent project.

Yeahhh.. Thank you😍 . for reading till the end. That's all for basic usage of git and github that I collected. Please let me know in comments if you have any questions for me.

Thanks guys!😎