Posts

Showing posts with the label Git and Github

Git Branch and Fork Differences explained

In this article, we will learn about the differences between git fork and branch. To learn about some Git terms you can refer to this blog post. What is a Git branch? A branch represents a line of development. Often, developers use different branches for production releases, bug fixes, etc. Having code in different branches enables developers to make changes to code without messing up the main line of development. What is a Git fork? Forking is the process of copying someone else’s repository into your own account. So, when you fork a repository, a copy of the entire repository is available in your own account. Forking is typically used when developers want to make changes to someone else’s repository for their own purpose. Forking does not in any way affect the original repository. Developers can however submit their changes to the project owner by creating a pull request. Differences between a branch and a fork The following table lists the differences between a branch and a fork: E...

Git commands CheatSheet - List of most used Git commands

In this article, I will be listing some of the important Git commands along with their syntax and examples. This article is aimed to be a Git commands cheatsheet for developers. Important Git Commands git init The git init command creates a local repository.  It creates a hidden .git folder that represents the local repository . Syntax git init Examples git init      # Initializes the current directory as a git repository git init <path> # Initializes the specified directory as a git repository git add The git add command adds files to the git staging area Syntax git add <filename> Examples git add Hello.java # adds Hello.java git add . # adds everything from the current directory recursively OR git add -A # same as git add . git commit The git commit command adds files to the local repository . You can use it to add a single file as well as a bunch of files. Syntax git commit -m "<msg>" Examples git commit -m "Initial commit" git commit -am ...

How to Create a Remote Github repository

Image
In this article, I will be listing down a few basic instructions to create a remote repository in git. Creating a remote Git repository is a two-step process. First, you need to create a remote repository on your Git hosting system (Github) and then you can push your local changes to it. Let us now take a look at these steps. Creating a repository on Github Step 1: Go to Github.com. Sign in/Sign up Step 2: Click on the “+” sign in the top right and click New Repository: Step 3: In the new repository page, enter the name ( github-demo ). Click on the checkbox to “ Add a Readme ” file. Add a description if required. Click on “Create Repository” : This creates a repository as follows:   Create a Local Repository The next step is to create a local git repository. For this, you need to follow the steps given below. Step 4: Open a command prompt/terminal window/git bash prompt Step 5: Clone the newly created repository by running the following command...

Some Git Terminologies Explained in Brief

In this article, I will try to explain some of the important terminologies associated with Git. Some Git Terms Working Directory Working directory refers to a project folder on the file system. It may or may not be tracked by Git. Staging Area A staging area represents the files that are ready to be added to a repository. Typically, projects include dynamically generated files like class files, test reports, etc. These are not added to a repository, only the source code/configuration files are added to a repository. Thus, whenever you want to add some code to a repository, it first needs to be added to the staging area, from where it can be committed to the repository. The process of adding code to the staging area is known as indexing . Local Repository As explained in my Git v/s Github article, Git maintains a local repository where it keeps track of all the changes made to the project on the local system. Remote Repository The repository on your repository hosting system like Githu...

Git and Github Differences Explained In Short

Often, the terms Git and Github are used interchangeably. Those new to Git and Github often find this confusing. In this post, I will try to clear some confusion. What is Git? In very simple terms, Git is a local version control system. Unlike other version control systems like SVN and CVS, it creates a local repository. It can be used to track changes to files. What is Github? Github is a git repository hosting service. It can be used to share git repositories across teams.  In addition to Github, there are other git repository hosting services like Gitlab, Bitbucket, etc. Git and Github Differences The following table lists the differences between Git and Github: Edit Git Github Version control system that can be used to track changes to files Git repository hosting service that can be used to share git repositories across teams. Is a command line tool Has a Graphical User Interface Needs to be installed locally on the system Does not require any additional software to be ins...

Create a local repository in Git with step by step commands

In this article, I will be listing down a few basic instructions to create a local repository in git. Step 1: Open a command prompt/terminal window. Navigate to the directory where you want to create a git repository. Step 2: Initialize the directory as a local repository using the following command: git init Step 3: Add the files from the current directory to the local repository: git add .   Step 4: Commit files to your local repository: git commit -m "Initial commit" That is all!