Must known Github codes

My Journey of Github

Image used from Unsplash.com
Image used from Unsplash.com

Understanding the GIT Workflow:

GIT is the most widely used open-source VCS (version control system) that allows you to track changes made to files. Companies and programmers usually use GIT to collaborate on developing software and applications.

A GIT project consists of three major sections: the working directory, the staging area, and the git directory.

The working directory is where we add, delete, and edit the files. Then, the changes are staged (indexed) in the staging area. After we commit our changes, the snapshot of the changes will be saved into the remote git directory.

Everyone can use GIT as it is available for Linux, Windows, Mac, and Solaris. If you look for a quick look you can check about git here . All the necessary steps are well described here. It may help new developers.

Image used from Unsplash.com

Version control system:

It is like taking pictures of a living animal in different age with different device and compare, analyse and choose the best one. A version control system, or VCS, tracks the history of changes as people and teams collaborate on projects together. As the project evolves, teams can run tests, fix bugs, and contribute new code with the confidence that any version can be recovered at any time. Developers can review project history to find out:

#Which changes were made?#Who made the changes?# When were the changes made?# Why were changes needed?

Github and Version Control in a nutshell:

These are the buzzword when developers develop a project and must have a crystal clear concept of all these topics.

  • Repository: A repository short form is called Repo is a project that contains multiple files. In our case a repository will contain code-based files.Repository is a central location in which data is stored and managed.
  • Commit: Commit is an operation which saves the changes permanently.This is maybe the most-used command of Git. Once we reach a certain point in development, we want to save our changes (maybe after a specific task or issue).Git commit is like setting a checkpoint in the development process which you can go back to later if needed.We also need to write a short message to explain what we have developed or changed in the source code. git commit -m ‘commit message’
  • Staging Area: Staging is a step before the commit process in git. That is, a commit in git is performed in two steps: staging and actual commit.
  • Push: The git push command is used to upload local repository content to a remote repository(in server).
  • Pull: The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content.
  • Remote Server: Remote server is a server which is not on a LAN (Local Area Network), it serves the data to the users across the globe.
  • Branch: The branch is like the directory of your project which contains all the files in it. Git repository always creates the default branch which is called master branch.
  • Clone: Clone is the process of creating copy of something.To clone a repo we have to write only this command in command line.Browse the Github and copy the link of cloning and run this command in your machine; git clone https:// repo link and the repo is downloaded in your local machine.

If we want to start using Git, we need to know where to host our repositories.

There are two ways you can host your repositories. One is online (on the cloud) and the second is offline (self-installed on your server).

There are three popular Git hosting services:

  1. GitHub: Owned recently by Microsoft — Launched in 2008 (31 million users in October 2018).

2.GitLab: Owned by GitLab Inc. — Launched in 2011.

3. BitBucket: Owned by Atlassian— Launched in June 2008.

We’ll use GitHub as our hosting service.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.

Basic Commands:

Before learning the basic commands of Github, let’s see what makes a developer happy at the end of a year.When a developer sees the seeds he/she bows in the ground and start growing……. and always fresh.

Contribution statistic of GitHub account (https://github.com/rieckpil)

Click here to find the procedure of opening your bank account of code.😃

#.Some of the basic commands for continuing with GITHUB:

  1. git status: This GitHub command is mainly used for identifying GIT created status in local repository. It provides proper information between a syncing status of local and GITHUB repository to the end user.
  2. git add your_file_name: Used for adding one specific file in staging area.
  3. git add –A: Adding all the files whether it is new or modified will be added in the staging area.
  4. git commits –m “your_message for commit”: Commit all the required changes.
  5. git rm –r your_file_name.doc: Helping for removing the file or any defined folder.

If you want to get clear info, it may be written for you.

Intermediate Commands:

There are several other popular commands which are used by the developer, which are not very basic commands but working with GITHUB more, those commands are very much required to execute. Some of these kinds require intermediate commands which are mentioned below:

  • Command for Branching and Merging multiple projects commits codebase.
  • Checking git status when you are working in group ; make it one of your habit, by checking(git status) it before pushing codes always keep you safe and relax.
  • Always keep your remote branch updated with the remote master.
  • My experience in coding ; several times I slipped 😕 for not taking pull from remote. Before starting your task when you are working in a group project never forget to pull and this will keep you always updated with the remote.

A.git branch: This is very much a useful command for using any kind of GITHUB set up for your projects. It normally provides entire branch information in a list.

B.git branch -a: This is helping for listing all the available branches considering all the locations of the branches, it can be local or remote. It is one of the key commands for identifying all the available projects in GITHUB environment.

C.git branch my_branch: Creating a new branch named my_branch.

D.git branch –d my_branch: Deleting the branch named my_branch.

E.git push origin –delete branch_name: Deleting a branch from the remote environment.

F.git checkout -b my_branch1: Helping to create one specific new branch named my_branch1and switching entire codebase to it.

G.git checkout –b branch_name origin/branch_name: Helping for cloning one remote branch and switching entire codebase to it.

H.git checkout any_name: Switching to a branch named any_name.

I.git checkout — :Switching to a specific branch which absolutely checks out last.

J.git checkout — file_name.doc: Avoiding or discarding the last changes in the specific file.

K.git merges branch_name: Helping for merging one specific branch with one of the other activities available branches.

L.git merges source_branch target_branch: Helping for merging with specified sourcing branch and specified target branch.

M.git stash: Stash helps in some of the specific changes to define dirty directory immediately.Often, when we have been working on part of your project, things are in a messy state and you want to switch branches for a bit to work on something else. The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later. The answer to this issue is the git stash command.

Stashing takes the dirty state of your working directory — that is, our modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch).

N.git stash clear: To delete all stashes in git, we need to run the git stash command all the stash entries from the dirty working directory will be deleted by following command.

when you need a help just type ‘git — help ' git is always there to help you.

Now We are in the apex of Github
Now We are in the apex of Github
Image used from Unsplash.com

Advanced Commands

Sometimes some critical tasks need to be done by the GitHub users frequently. Those tasks also have some advance kind of commands which needs to be executed.These commands are must known to a developer to grow and to acquire a good command in git; which are mainly used by some of the managerial people for understanding projects status comparing other existing project and also sometimes used for sharing some project knowledge with others. These advanced commands are mentioned below:

  • These are the commands for updating or sharing projects data:

A.git push origin branch_name: Helps for pushing one of the created branches in your local environment to a remote directory or repository.

B.git push –u origin branch_name: It does the similar task like above, pushing entire local repository branch to the remote repository, extra utility of using this command is also remembered for this specific branch for future reference.

C.git push: Again it does the same task, pushing entire local repository data to the remote, but do not need to mention the branch name, it will pick up branch name directly from the last remembered branch.

D.git push origin — delete my_branch: Deleting specified branch.

E.git pull: Helping for updating all the newest commit in the mapping local repository.

F.git pull origin branch_name: Helping for pulling entire changes from the specific remote repository to local.

G.git remote add origin ssh://something.com/user_name/repository_name.git: Helping for mapping local repository’s origin branch with remote repository through SSH.

  • Commands for Comparison or specific inspection on GITHUB repository:
  1. git log: Displaying all the log information of one specific project, which can provide every information with committed changes.
  2. git log –summary: Provide more log details for identifying specific members who committed the same.
  3. git diff source_branch target_branch: This one normally is used before merging on a specific document. It helps for displaying current changes done on the existing document.

Some regular based insanely important git commands.Take a look in this blog.These codes are almost useful like our daily necessities.

Git cheat sheet here.This git cheat sheet contains the most important and commonly used Git commands for easy reference. Take a look if you want to revise the commands.

rahman_mahbubur. JavaScript, Python and AWS enthusiast!!

want to seed at least one seed daily in github.