Git and GitHub - The Game Changer

Git and GitHub - The Game Changer

Day 8 of 90daysofdevops

·

6 min read

Hello Readers,

Here we are Day 8 of #90daysofdevops

👣 Topics for #day8

  • Git

  • How Git works?

  • GitHub

  • How to use GitHub?


Git

Git is a distributed version control system designed to track changes in source code during software development. It allows multiple developers to work on the same codebase simultaneously and provides tools for managing conflicts and merging changes.

In simple terms, Git helps teams collaborate more effectively and keep track of changes made to their code over time.

Git is a Command Line Tool.

How Git works?

fortynnet Stortinget Zeal utgangspunkt Brandy tilbake how does git work -  jrwetlands.com

Example on how Git works:

  • Let's say you're working on a project with a team of developers, and you're all using Git to manage the source code. You start by creating a Git repository, which is a directory that contains all the project files and their version history.

  • One day there was a requirement to change something in the code.

  • To make the changes to the code, you first have create a branch, which is a copy of the main source code that you can work on independently. You make your changes to the code on your branch, and then you commit those changes to your branch's version history.

  • Meanwhile, there was another requirement to change the code and that should be done by another team member.

  • The other team member has also made changes to the main source code on their own branch, and they've committed those changes to their branch's version history.

  • Now, both you and the other team member want to merge your changes back into the main source code. Git provides tools for comparing the changes you've made on your branch with the changes made by the other team member, and for resolving any conflicts that may arise.

  • Once any conflicts are resolved, you can merge your changes back into the main source code, creating a new version of the code that includes both your changes and the changes made by the other team member.

  • This process of creating branches, making changes, and merging them back into the main source code is the core of how Git works. By using Git, teams can work together more efficiently and effectively, while still maintaining a clear record of the changes made to the code over time.


Few commonly used Git commands:

  1. git init: Initializes a new Git repository in the current directory.

  2. git add: Adds changes to the staging area, which prepares them to be committed to the repository.

  3. git commit: Commits changes to the repository, creating a new version of the code with a commit message that describes the changes.

  4. git status: Shows the current status of the repository, including which files have changes that are staged or unstaged.

  5. git log: Shows a list of all the commits in the repository, along with their commit messages and other information.

  6. git branch: Shows a list of all the branches in the repository, and also allows you to create, rename, or delete branches.

  7. git checkout: Switches to a different branch, either by creating a new branch or by checking out an existing one.

  8. git merge: Merges changes from one branch into another, creating a new commit that includes both sets of changes.

  9. git pull: Fetches changes from a remote repository and merges them into the current branch.

  10. git push: Pushes changes from the current branch to a remote repository, making them available to other team members.


GitHub

GitHub is a web-based platform that provides hosting for Git repositories. It offers additional features on top of Git, such as a GUI for managing repositories, collaboration tools like pull requests and issues, and integration with other services like continuous integration and deployment.

GitHub allows developers to store their code repositories in the cloud, making it easy to collaborate with other team members and work on code from multiple devices. It also provides tools for managing code reviews, testing, and deployment, making it a popular platform for software development teams.

GitHub also provides a range of social features, such as the ability to follow other developers, star repositories, and contribute to open source projects.

How to use GitHub?

Why should software developers have all the fun?


  • Let's say you're working on a software development project with a team of developers. You decide to use Git for version control, and GitHub for hosting your Git repositories and collaborating with your team.

  • First, you create a new repository on GitHub by logging into your account and clicking the "New" button. You give the repository a name and a description, and then you create it.

  • Next, you clone the repository to your local machine using the git clone command. This downloads the repository and sets up a local copy on your computer.

  • You then create a new branch in the repository using the git checkout -b command. This creates a new copy of the source code that you can work on independently of the main branch.

  • You make some changes to the code on your branch, and then you use the git add and git commit commands to stage and commit your changes.

  • Now, you want to share your changes with the rest of the team.

    You use the git push command to upload your changes to the remote repository on GitHub.

  • At this point, you create a pull request on GitHub, which is a request for the rest of the team to review your changes and merge them into the main source code. You add some comments and notes to the pull request, and then you submit it.

  • One of your team members sees the pull request and reviews your changes. They make some comments and suggestions, and you have a discussion about the changes.

  • You make some updates to your code based on the feedback you received, and then you push those changes to the remote repository.

    Your team member approves the changes, and then they merge your branch into the main branch using the "Merge Pull Request" button on GitHub.

  • Finally, you use the git pull command to download the latest changes from the remote repository to your local machine. You now have the latest version of the code, including your changes and the changes made by your team members.

    This is just one example of how GitHub can be used for collaboration and version control in a software development project.

GitHub Interface


Thank you for reading my Blog. I hope you have learnt something from it! If you find this blog helpful, please like, share, and follow me for more interesting posts like this in the future.

Pavan Kumar R

Please navigate to my GitHub Repo: GitHub Repo Link

to check my solutions for the tasks of 90daysofdevops Challenge.

LinkedIn Link

Â