- #What is git bash and why do we use it how to#
- #What is git bash and why do we use it full#
- #What is git bash and why do we use it code#
Refer the image below to see how branches work. Multiple branches are needed to support multiple parallel developments. So currently our master branch is a pointer to the second commit “demo.txt file is modified”. What is a branch?Ī branch is nothing but a pointer to the latest commit in the Git repository. By default, Git commits go into the master branch. Up until now we have not created any branch in Git. The log shows the author of each commit, the date of the commit, and the commit message. Use git log to print out all the commits which have been done up until now. Now let us add demo.txt to the staging area and commit it using the following commands: git add demo.txt git commit -m "demo.txt file is modified" Log The status shows that demo.txt is modified and is not yet in the staging area. Use the following command to see the status: git status Use git status to find out information regarding what files are modified and what files are there in the staging area - it shows other information as well, which we can ignore for now. Now modify the demo.txt file and add the following snippet: Initial Content Adding more Content Status
#What is git bash and why do we use it code#
Enter a relevant commit message to indicate what code changes were done in that particular commit. “Initial Commit” is the commit message here. Use the following command to commit the file: git commit -m "Initial Commit" Use this carefully since it adds all the files and folders in your project to the staging area. If you want to add all the files inside your project folder to the staging area, use the following command: git add.
In case you want to add multiple files you can use: Use the following command for staging the file: git add demo.txt This gives the developer control over which files need to be committed. The staging area is there to keep track of all the files which are to be committed.Īny file which is not added to the staging area will not be committed. Before committing the code, it has to be in the staging area. Staging and Committing the codeĬommitting is the process in which the code is added to the local repository. Here we will be demoing with just plain text instead of actual code, since the main focus of this article is on Git and not on any specific programming language. Let’s Add some Small Code nowĬreate a file called demo.txt in the project folder and add the following text into it: Initial Content The git init command adds a local Git repository to the project.
Go into your project folder and add a local Git repository to the project using the following commands: cd simple-git-demo Let’s call the project folder simple-git-demo. In your computer, create a folder for your project. Verify if Git is installed by using the following command in the command prompt: git -version Create your local Git repository
#What is git bash and why do we use it how to#
This link has details on how to install Git in multiple operating systems: Rather than mentioning all the concepts at once, I will explain the concepts of Git through an example so that it is easier to follow. In such a case, the concept of branching in Git is very important. So a version control system allows developers to revert and go back to an older version of the code.įinally, sometimes several projects which are being run in parallel involve the same codebase. So a version control system like Git is needed to ensure there are no code conflicts between the developers.Īdditionally, the requirements in such projects change often. Real life projects generally have multiple developers working in parallel. Why a Version Control System like Git is needed I will explain the concept of remote and local repositories later in this article.
Git is a Distributed Version Control System since the code is present in every developer’s computer.
#What is git bash and why do we use it full#
This means that the code is not just stored in a central server, but the full copy of the code is present in all the developers’ computers.