Git & GitHub
Piyush Lakheda
Software Engineer I @Hashedin by Deloitte| MEAN | Python & GenAi | Public Speaker ???
“We are all in on open source."
-Satya Nadella
What is Git?
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.
Git does not necessarily rely on a central server to store all versions of a project's files. Instead, every user clones a copy of a repository and has the full history of the project on their own hard drive. And the data is stored on a self-hosted server or a third-party hosting service like GitHub.
Why use Git & GitHub?
- Undoing mistakes is easier and flexible.
- Parallel work or distributed development is supported.
- Provide the option of branching for clean work.
- Community support.
Git installation:
Step 1.: Go to https://git-scm.com/downloads
Step 2: Select the OS type as per your device and then the download of the setup will start.
website:
What is GitHub?
GitHub is a platform for Internet Hosting for software development and version control using Git. It offers the distributed version control and source code management functionality of Git, plus its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, continuous integration, and wikis for every project.
How Git & GitHub Works?
Key terms:
- Repository: It is a kind of container for a project you want to track using Git over GitHub.It is abbreviated as "repo" sometimes.
- Commits: These are the checkpoints for your projects at which you can come back anytime to resume from there or these are kind of saved files for your modified project.
You can work over Git & GitHub in two ways:
- Git Command Line: You can use CLI(command line interface) over "GitBash" which is a terminal installed after you install Git in Windows. Also, you can use "Command Prompt" to run commands.
Link for documentation of the commands: https://git-scm.com/docs
- GitHub Desktop: It provides a user-friendly interface so that you can manage your repository in a convenient manner. Also, it's helpful as you don't have to struggle with the Git commands.
Working
- Working Directory: It is the Local directory over which you work on your project and make changes. Then the created files are added to the staging area by the command -git add
- Staging Area: Staging Area contains the files that have been tracked or in which Git has been initialized. Files that you want to commit need to be first tracked in the staging area. It's important to note that as long as files are in the staging area they can be modified.
- Git Directory/Repository: As mentioned above, the repository is a container that saves your modified files or projects after you commit from the staging area.
Branching
Using branches helps you to distribute the work among team members and other developers while keeping your master branch(i.e main branch) clean. The Master branch is the main branch that contains your main project.
While working over a running project it is possible to have different features or ideas ready to merge into the project for deploying. so, branches help in managing them.
There's only one rule: anything in the main branch is always deployable.
Because of this, it's extremely important that your new branch is created off of main when working on a feature or a fix. Your branch name should be descriptive. so, that others can see what is being worked on.
Changes you make on a branch don't affect the main branch, so you're free to experiment and commit changes, safe in the knowledge that your branch won't be merged until it's ready to be reviewed by someone you're collaborating with.
Workflow:
-git add: it add the files to the staging area so that they can be tracked.
-git commit: commits the changes and the files to the local repository head.
-git push: push the committed files to the remote repository in the main branch.
-git merge: it is used to do the actions of both "-git add and -git commit".
-git pull: it pulls any file from the remote repo over GitHub to the working directory.
- Forking: It is basically copying the repo in your account rather than the account from which you forked the data. Once you forked the repo you are free to edit the repo and modify it.
- Cloning: This works the same as the fork does i.e make a copy of the existing repo. But the only difference is that in forking a repo it is copied to your GitHub account and when you clone the repo then it is stored in your local machine.
- Pull request: It helps you to tell the other developers about the changes you have made into the other repository and once it is reviewed you can discuss them with other contributors.
That was a try to cover the major and basic portion of Git and GitHub so that beginners can get a basic idea of them.
Thanks and Keep learning.
Agencies & Ecom
3 年Very Informative ??
Software Engineer @ Wayfair ? Ex-Microsoft ? Full Stack Developer ? MERN Stack Developer
3 年Great work Piyush, insightful!!
Research Intern @UTB Czech Republic || 2× Google Cloud CR Mentor || Founding Organiser @JECRC Cloud Summit || Google Cloud CF Mentor || Mentor @Coding Ninjas JU
3 年Really helpful! Piyush ?
Data-Driven Business Storyteller | Analytics Enthusiast | Merging Content Strategy with Data Insights
3 年Really Informative!!?? Piyush Lakheda
Technical Consultant @ Duco Consultancy ? xIISc | GOI ? Gen AI | Data
3 年Awesome work Piyush Lakheda ?