Getting Started with Git and GitHub
It has following 2 modules…
It has following 2 modules…
Working without Version Control:
Working with Version Control:
SSH protocol – A method for secure remote login from one computer to another.
Repository – The folders of your projects that are set up for version control.
Fork – The process you use to request that someone reviews and approves your changes before they become final.
Working directory – A directory on your file system, including its files and subdirectories, that is associated with a git repository.
Background of Git:
Git Repository Model:
What is special about the Git Repository model?
Created in 2005 by Linus Torvalds
What is Git?
Git is a distributed VCS
Git allows for centralized administration
IBM Cloud is built around open-source tools including Git repositories
GitLab is:
A DevOps platform, delivered as a single application
Provides access to Git repositories
Provides source code management
GitLab enables developers to:
Collaborate
Work from a local copy
Branch and merge code
Streamline testing and delivery with CI/CD
What are branches?
Merging Branches:
What is a Pull Request?
A PR makes the proposed (committed) changes available for others to review and use
A pull can follow any commits, even if code is unfinished
PRs can target specific users
GitHub automatically makes a PR if you make a change on a branch you don’t own
Log files record the approval of the merge
Merging into the Master/Main Branch
The master branch should be the only deployed code
Developers can change source files in a branch, but the changes are not released until
Pull command is issuedPowerful tools include forking and cloning a repository
Cloning creates a copy of a repository on your local machine
Cloned copies can sync between locations
Forking modifies or extends a project
Remote Repositories:
Remote repos are stored elsewhere
Push, pull, and fetch data to share work
Origin refers to your fork
Upstream refers to the original work
Syncing a Fork of a Project:
To keep a fork in sync with the original work from a local clone:
Create a local clone of the project
Configure Git to sync the fork
git remote -vgit remote add upstream <clone repo url>git remote -vCommands for Managing Forks:
To grab upstream branches
git fetch upstreamTo merge changes into the master branch
git merge upstream/masterGitHub Developer:
A Developer communicates with others using these commands:
git-clone from the upstream to prime the local repositorygit-pull and git-fetch from “origin” to keep-up-to-date with the upstreamgit-push to shared repository, if you adopt CVS style shared repository workflowgit-format-patch to prepare email submissiongit-send-email to send your email submission without corruption by your MUA (Mail User Agent)git-request-pull to create a summary of changes for your upstream to pullGitHub Integrator:
An integrator
Receives changes made by others
Reviews and responds to PRs
Publishes the result for others to use
Integrators use the following commands:
git-am to apply patches emailed in from your contributors
git-pull to merge from your trusted lieutenants
git-format-patch to prepare and send suggested alternatives to contributors
git-revert to undo botched commits
git-push to publish the bleeding edge
GitHub Repository Administrator
A Repository Administrator sets up and maintains access to the repository by developers
git-daemon to allow anonymous download from repositorygit-shell can be used as a restricted login shell for shared central repository usersgit-http-backend provides a server-side implementation of Git-over-HTTP (Smart HTTP) allowing both fetch and push servicesgitweb provides a web front-end to Git repositories, which can be set-up using the git-instaweb script