Table of contents
No headings in the article.
GitHub is a collaborative platform for software development, offering a centralized space for managing and tracking code changes. It enables teams to work together seamlessly, with features like version control, issue tracking, and project management tools. GitHub simplifies code sharing, allowing developers to collaborate, edit, and share code effortlessly.
Git is a DevOps tool used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to track changes in the source code, enabling multiple developers to work together on non-linear development.
Points to be Remember😐:
- A repository is a container for tracking projects using Git.
- Multiple repos can be created for different projects on your computer.
- Repositories can be either local (on your computer) or remote (hosted online, like GitHub or GitLab).
- Git tracks the contents of a project folder, allowing for easy collaboration and version control.
- Repositories serve as organized spaces to manage and monitor the development of projects.
- Commits in Git allow us to roll back to any previous point in the project lifecycle.
- We can also fast-forward to more recent commits from a previously committed state.
Stages of a File
- The untracked stage refers to files that have been modified but are not being tracked by Git for committing.
- In the staging stage, we selectively add files that we want to commit and track changes to.
- It is not recommended to use "git add ." as it adds all files and folders in the project. Instead, we can use "git diff" to view differences between the current and previous versions of a file and add specific files using "git add myfile.txt" (replace "myfile.txt" with the relevant file name).
- At the Committed stage, there is a primary branch known as "master" or "main".
- From the primary branch, we can create new branches and make separate changes.
- These branches enable us to work on new features without modifying the code in the master branch.
- Eventually, the changes from the new branches can be merged back into the master branch.
Branches:
- Initially, we work on a single branch, usually called "master," which represents the current state or version of the code.
- To avoid potential issues with the code, it's not recommended to try out new features directly on the master branch, Instead, we create isolated environments called branches to test and develop new features independently.
- By creating a branch from the master branch, we essentially make a copy of the code's state to work on. We can also then make commits and test the new features on the branch. If everything goes well, we can merge the branch back into the master branch, creating a "merge commit."
- However, if something goes wrong in the branch, we can simply delete it without affecting the master branch. Branching is especially useful when multiple developers are working on different features simultaneously. They can each create their own branches, work on their respective features, and merge their changes back into the master branch when ready.
Merging:
- To perform a merge, be on the branch you want to merge changes into.
- For example, if you have branches named feature-1 and feature-2 and want to merge them into the master branch, switch to the master branch first.
- Execute the merge commands after being on the desired branch.
- This ensures that the changes from the specified branches are integrated into the target branch effectively.
- GitHub is a service that allows us to create hosted repositories.
- It provides a centralized online remote repository where team members can collaborate.
- Team members can clone the online repository to their local computers, creating a local version of the repository.
- They can work on specific files by creating branches.
- Once everyone is satisfied with their changes, they can push the code back to GitHub and merge it into the master branch.
- Other team members can then pull the merged code into their local computers, ensuring everyone stays in sync with the main codebase.
Please find all the GitHub commands ➡️ For Commands Click here
I hope this blog finds you helpful, Lastly, don't forget the impact you can have on others. Your kindness, compassion❤️, and support can make a world of difference to someone in need. Be a source of positivity and spread love wherever you go.
Feel Free to reach out to me😌: at kotta.mssjmanvith.20cse@bmu.edu.in