Git is an open-source distributive version control system, we can also call Git as a type of Backup, Git holds the history of all kinds of operations that you have done in each updated version, it also tracks the files, holds commit history, and allows you to make changes, undo changes you have made before. Git allows one or more people to work as a team on the same project, and we call this process as a collaboration.
Git Workflow Cycle
Here we will go through the basic Git workflow and some basic key concepts.
A working directory is used to modify the files, where it is a directory or folder on the computer which contains all the project or application files. The files within the working directory may or may not be controlled by the Git. There will be a hidden folder called .git folder that contains the actual git repository.
The staging area is also called Index, where the staging area holds /keeps all the files that are in the queue for the next commit. The files which are present in the staging area are not committed yet. we can move the files in and out from the staging area without affecting the git repository and its history of changes.
Once you perform commit operation, git sends files from the staging area to the repository. Once you complete the push operation, it will permanently store the changes in the git repository.
Git Repository is the one that contains all the files concerning the specific project application. Git Repository also includes a commit history and unique configurations in it.
GitHub is a Web-Based Hosting service mostly used for version control Systems through Git. It lets you and others work together on projects from anywhere.
Now to understand the entire Git workflow in the local and Remote side, we need to create a remote repository by using the GitHub, Then we can replicate the remote repository in the local system.
+sign, you will be suggested with a new repository, new project, etc.. select
README.mdand click on Create Repository.
Before we are proceeding further with Git, we need to configure the Git repository. Git Requires two information such as username and email id.
$ git config --global user.name "your username"
$ git config --global user.email "your email id"
$ git clone https://github.com/goldsi/github_demo.git
$ lsthen it will list all the files which are present in the project folder, then do
cd github_demo/you will be directed to the github_demo.
$ git statuscommand the repository tell us that it is on its master branch where the master branch is the default branch for Git Repository.
$ echo "test quick start" >> great.txt
lscommand, you can see the great.txt file in the working directory.
$ cat great.txta command to see the content of the text file.
$ git add great.txt
$ git commit -m "adding text great txt file"Hence it will give you the below output
$ git push origin master
Git for Windows provides a BASH emulation used to run Git from the command line.
Navigate to https://gitforwindows.org/, gitforwindows page will open as shown below and then click on the download button.
Once the application has downloaded, click on the download file and select
Next, the application starts installing on your system. Once it completes installing, click on
Go to the project folder and right-click on the folder DesktopApplication, in the drop-down list you will find the GitBash here option.
If you click on the Git Bash Here, the Git bash emulator will open.
Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub. I have created my new repository
Flight Application as shown below
Open Git Bash from your project folder, just open your project folder, right-click on it and select Git Bash Here.
Configure the Github username and password to create our identity by using the command
$ git config --global user.name "snapp123" and the password
$ git config --global user.email [email protected]
Initials the local directory as a Git repository by using the command
$ git init
Add the files in your new local repository by using the command
$ add .
After adding the file from the local repository, we need to commit by using the command
$ git commit -m "This is my First Commit", once you commit the below files, are created in the remote repository.
Next step is to add the origin/URL of the git repository, go to the GitHub page you will find the Github URL as shown in the below image.
Copy and paste this in the git bash by using the command
$ git remote add origin https://github.com/snapp123/Flight-Application.git, now we have connected our local repository to the remote repository.
Verify our repository by using the command
$ git remote -v, now you can see our remote repository Flight Application fetch and push message, as shown below.
Now we have to push the changes in your local repository to GitHub by using the command
$ git push origin master, once you run this command you will be prompted to enter the username and password
Enter the username and password and click on
Login, you can see the push message in the git bash, as shown below.
Now go to the GitHub and open your repository, you can see all the keywords and test cases created over there.