Table of contents
- What is a version control system (VCS)?
- What is GIT?
- How does Git works?
- What is GitHub?
- Git v/s GitHub
- What is commit?
- What is pull requests in GitHub?
- What is fork and why to fork?
- What are branches in Git and Github and why is it important to always create a different branch for different projects?
- Steps involved in working with Git:
- All the important codes
- Fix Git proxy settings:
What is a version control system (VCS)?
Version Control System (VCS) is a software tool that helps manage and track changes to files and folders over time. It is typically used in software development to keep track of changes made to source code, but it can also be used to manage other types of files, such as documents, graphics, and configuration files.
A popular example of a version control system is GIT.
What is GIT?
GIT is version control system that does all the things that a version control system does as stated above with extra features.
Git allows developers to keep track of changes made to their code over time, collaborate with other developers on a project, and easily revert to earlier versions of their code if necessary.
The main feature of a git is that Git makes it easy for multiple developers to work on the same codebase without conflicts by allowing them to work on separate branches and merge their changes together later.
How does Git works?
Git works by keeping track of changes made to files in repository over time.the basic workflow in Git involves creating a local copy of a repository, making changes to files, and then committing those changes back to the repository.
What is GitHub?
GitHub is a web platform where all developers store there code.
Beside from storing code it provide us with different developers from around the globe that we can connect with and collaborate with different projects.
Some of the features of GitHub are:
GitHub includes tools for managing issures, tracking bugs, and collaborating on code with developers.These features make it easy to work on porjects with team.It also hass a large and active open-source community, makin it easy to find and contribute to open-source projects. It's a grat place for developers to showcase their work and connect with other developers.
Other additional features of GitHub include that it provides integration with various continuos integration and deployment tools, making it easy to build, test and deploy code changes automatically.
Git v/s GitHub
Git is the version control system itself, while GitHub is a hosting service that provides a user interface and additional collaboration tools for Git repositories.
What is commit?
A commit is a snapshot of the current state of a repository at a given point in time. It includes all the changes made to the files and directories in the repository since the last commit.
What is pull requests in GitHub?
Pull requests allow developers to suggest changes and get feedback from other developers before merging changes into the codebase.This ensures that changes are thoroughly reviewed and tested before they are added to the codebase.
What is fork and why to fork?
A fork is a new repository that shares code and visibility settings with the original upstream and copies all the codes and saves to your github account so that you can edit the code and contribute to the project and then merge it. It is important because it is not safe to modify the main code , and after finishing the project we can commit(which will be discussed below) and pull request can me made.
What are branches in Git and Github and why is it important to always create a different branch for different projects?
A branch is a separate line of development that diverges from the main line of development. It allows developers to work on different features or changes in isolation without affecting the main codebase. Branches help us clear the confusion between developers in a large project so that there is no confusion about which issues are getting fixed and which is not.
It is important to create different branches for different projects to avoid conflicts and maintain the integrity of the main codebase. By working on different branches, developers can experiment with new features, try out different ideas, and collaborate on different aspects of the project without interfering with the main codebase.
Steps involved in working with Git:
Create a repository: A repository in a directory where your code files are stored.
Create a repository: To start using Git, you need to create a repository, which is a directory where you store your code files.
Create a local copy: You can create a local copy of the repository on your computer by cloning it from a remote repository or creating a new local repository.
It is important to create a local copy of the system so that you can use it and get the issue fixed , and it is not possible unless you use the whole code in your local machine and feel the issue.
Make changes: You can edit the files in your local copy of the repository. Once you have made the changes, you can stage them for a commit.
Stage changes: Git allows you to stage specific changes you have made to files in the repository. You can use the
git add
command to stage the changes.Commit changes: After staging the changes, you can commit them to the repository using the
git commit
command. This creates a snapshot of the changes you have made.Push changes: If you are working with a remote repository, you can push your changes to it using the
git push
command. This updates the remote repository with your changes.Pull changes: If you are working with a remote repository and other developers have made changes to it, you can pull those changes into your local copy using the
git pull
command.Git push : After modifying all the required code bases we need to add the changes in the github account current repository that we have forked in our account. These is done with the help of
git push origin <name of the branch>
Thus all the changes are made and we need to make a pull request with the original orgainisation where we request with our issue fixed.
Enjoy!
All the important codes
Setup and configurations:
git config --global user.name <firstname lastname>
It sets the user name
git config --global user.email <your email>
It sets the email
git init
This helps to initialize each of the folder in your local system to get started using the git
git clone <url>
It retrieves an entire repository from a hosted location via URL
git status
It shows modified files in working directory staged for next commit
git add <file>
It add a file for next commit
git diff
It shows the differnce of what is changed but not staged
git commit -m <descriptive message to commit>
git branch
List all the branches
git branch <branch name>
Creates a new branch
git checkout
It switch to another branch and check it out into your working directory
git log
shows all commits in the current branch's history
Fix Git proxy settings:
For those of the folks living in hostel like me they have an ethernet with a proxy and port.
So to connect using that internet we need to set proxy separately in our Git cmd
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
To reset the proxy:
git config --global --unset http.proxy
To check the current proxy:
git config --global --get http.proxy
Thanks for taking your time and reading my blog.