Day 9 - Deep Dive in Git & GitHub for DevOps Engineers

Day 9 - Deep Dive in Git & GitHub for DevOps Engineers

What is Git and why is it important?

Git(Global Information Tracker) is nothing but a source-code management tool used to manage code versioning and track developers' activity. Git tracks the changes and activity of developers working on a common project. Each developer can ‘pull’ the code, ‘add’ changes, ‘commit’ these changes, ‘push’ to the repo and then ‘merge’ with the main code. Each developer can make a ‘branch’ for his set of work.

The reasons behind git importance are:

  • Version control

  • Tracking the changes and updates

  • Branching

  • Being free and open source

  • Allowing to work collaboratively

What is the difference Between Main Branch and Master Branch?

main or master is the default branch when you create a repository. A branch in Git is used to keep your changes. Each repository can have one or more branches. The default branch of any GitHub repository is the main and for local repositories, it's the master.

Can you explain the difference between Git and GitHub?

Git is a tool that’s used to manage multiple versions of source code edits that are then transferred to files in a Git repository, GitHub serves as a location for uploading copies of a Git repository.

Git is a software.

GitHub is a service.

Git is a command-line tool

GitHub is a graphical user interface

Git is installed locally on the system

GitHub is hosted on the web

Git is maintained by linux.

GitHub is maintained by Microsoft.

Git is focused on version control and code sharing.

GitHub is focused on centralized source code hosting.

Git is a version control system to manage source code history. 
 

GitHub is a hosting service for Git repositories.

Git was first released in 2005. 
 

GitHub was launched in 2008.

Git has no user management feature. 
 

GitHub has a built-in user management feature.

Git is open-source licensed.

GitHub includes a free-tier and pay-for-use tier.

Git has minimal external tool configuration.

GitHub has an active marketplace for tool integration.

Git provides a Desktop interface named Git Gui.

GitHub provides a Desktop interface named GitHub Desktop.

Git competes with CVS, Azure DevOps Server, Subversion, Mercurial, etc.

GitHub competes with GitLab, Bit Bucket, AWS Code Commit, etc.

How do you create a new repository on GitHub?

  1. Go to github.com and log in to your account.

  2. In the upper-right corner, Click the "+" and select New repository from the dropdown.

  3. Enter a name for your repository.

  4. Add a description if you like (optional)

  5. Choose whether you want the repository to be public or private.

  6. Add a README file.

  7. Click the “Create repository” button.

What is the difference between local & remote repository? How to connect local to remote?

Git local repository is the one on which we will make local changes, typically this local repository is on our computer. Git remote repositories are hosted on a server that is accessible to all team members.
Navigate to the local repository on your system and use this command to connect local to remote.
git remote add origin <remote_repo_URL> git push --all origin
If you want to set all of your branches to automatically use this remote repository when you use git pull, add --set-upstream to the push:
git push --all --set-upstream origin

Task 1

Set your user name and email address, which will be associated with your commits.

To set the user name and email address, use these commands:
git config --global user.name "<username>" git config --global user.email "<email-id>"

Task 2

  • Create a repository named "Devops" on GitHub

  • Connect your local repository to the repository on GitHub.

    The git init command changes the current directory into a Git repository

    We can use this command to connect local repository to GitHub repository

    git remote add origin <GitHub_repository_url>

  • Create a new file in Devops/Git/Day-02.txt & add some content to it

  • Push your local commits to the repository on GitHub