m Github scm
Key Points
References
Key Concepts
Different Branching Strategies
https://www.flagship.io/git-branching-strategies/
git-branching-strategies-flagship.io-GitFlow Github Flow Trunk Based.pdf file
the Git branching model is lightweight compared to other version control systems; this is why it’s so easy and cheap to create branches in Git, as the whole code doesn’t need to be copied to the branch creating a large amount of duplicate files, as opposed to other VCS tools.
Client options to connect to Github
Web browser
Manage your Github repo online
Git client
GIT command line client interface to push, pull files to your Github repo
Github Desktop
A nice, free GUI desktop for Github Windows users
https://help.github.com/en/desktop/getting-started-with-github-desktop/overview
Install Github Desktop
Download from here for Windows
Login to your account
After installing Github Desktop, open it and hit Ctl + ( or File > Options ) to open up the login page
Take the option to create a new repository ( repo )
after making changes to a branch ( master or other ) on the local repo, commit the changes to the local branch
Then publish this repo from your local file system to the Github server
>> push the origin ( local ) to Github
the repo address:
https://github.com/jmason90/swt-hello1.git
Clone, Fork with Github Desktop
Connecting to Github
You can setup a direct account with Github for free or use an account setup by your organization.
After you have registered, consider using a secure connection to Github
In most cases, you'll prefer to have a secure TLS connection to Github using your PKI keys.
You check your profile on Github to see if you have a secure connection:
https://github.com/settings/keys
This shows I don't have SSH keys associated with my account for Github access
Connecting to Github with SSH keys
https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh
When you set up SSH, you will need to generate a new SSH key and add it to the ssh-agent. You must add the SSH key to your account on GitHub before you use the key to authenticate. For more information, see "Generating a new SSH key and adding it to the ssh-agent" and "Adding a new SSH key to your GitHub account."
To use your SSH key with a repository owned by an organization that uses SAML single sign-on, you must authorize the key. For more information, see "Authorizing an SSH key for use with SAML single sign-on" in the GitHub Enterprise Cloud documentation.
See
m Linux Remote Access Tools#KeyGenerationforaccesstoremoteservices(Githubetc)
m Linux Remote Access Tools#GeneratinganewSSHkeypair
Git and Github Basics Tutorial
https://towardsdatascience.com/getting-started-with-git-and-
github-6fcd0f2d4ac6
You’ll learn how to:
- Create and use a repository
- Start and manage a new branch
- Make changes to a file and push them to GitHub as commits
- Open and merge a pull request
create a branch
git checkout if the branch exists
git checkout [<branch>]
To prepare for working on <branch>, switch to it by updating the
index and the files in the working tree, and by pointing HEAD at the
branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.
git checkout -b|-B <new_branch> [<start point>]
Specifying -b causes a new branch to be created as if git-branch(1)
were called and then checked out.
pull requests
Pull Requests are the heart of collaboration on GitHub. When you open a pull request, you’re proposing your changes and requesting that someone review and pull in your contribution and merge them into their branch. Pull requests show diffs, or differences, of the content from both branches. The changes, additions, and subtractions are shown in green and red.
Using Github: Sample Development Workflows
https://hyperledger-fabric.readthedocs.io/en/latest/github/github.html
github-example-hyperledger-fabric.readthedocs.io-GitHub Contributions.pdf
To protect the Hyperledger Fabric source code, and maintain a clean state in the official GitHub repositories, Hyperledger Fabric GitHub pull requests are accepted from forked repositories only. The act of forking a GitHub repository creates an identical copy of the repository in your personal GitHub account. You are then able to edit code and propose these changes to the official Hyperledger Fabric repositories you forked the code from via the GitHub pull request process.
Simple push to remote IF the local branch is AHEAD of the target remote origin
3 way merge with GIT CLI
3. When a merge conflict happens during switching branches with the -m
option, you would see something like this:
$ git checkout -m mytopic
Auto-merging frotz
ERROR: Merge conflict in frotz
fatal: merge program failed
At this point, git diff shows the changes cleanly merged as in the
previous example, as well as the changes in the conflicted files.
Edit and resolve the conflict and mark it resolved with git add as
usual:
$ edit frotz
$ git add frotz
Using GIT commands from CLI offers a few extras
things to do from GIT CLI
clone
pull
list
add
set origin
push --dry-run
push --force
also: rebase, reset, pull request
Github changing services beyond SCM
Github was secure SCM for teams with integration points to JIRA, Slack etc
Github ( or GIT if hosted in-house ) has become the standard for SCM - source code management
Github now adding new services:
- CICD build pipelines billed as Github action minutes
- wikis
- project management
- code scans
- team collaboration
The strategy of expanding the Github suite creates 2 problems
- paying for services you don't need as in any suite bundle
- future added services in the bundle will increase licensing costs again
- dropping down to lower levels of functionality than competitive products
- the tools that have low usage in the Github suite will have more defects that take longer to fix ( Jim's "law of suites" )
CICD tool chains
- The negative on the CICD build services is the limits and overage charges set.
- This should be compared to the costs of running CICD leaders such as Jenkins or CircleCI on-premise or in the cloud
- Is it worth testing Github CICD actions ? only if compared to the current CICD leaders which are compatible with any environment
- Jenkins
- using Docker containers in Jenkins CICD flows
- using Docker containers in Jenkins CICD flows
- Circle CI
- Jenkins
Other Github services
While any of these add on services are useful to some degree, they won't compare to the industry standard tools in these areas
Jira is far better for managing Sprints, Kanban ( https://www.atlassian.com/software/jira/features )
Confluence is a better wiki solution and knowledge base ( https://www.atlassian.com/software/confluence/features )
MS Project handles project management better ( even GSuite GSheets can do basic project management better ) ( https://gsuite.google.com/features/ )
OWASP tools are free and the industry standard for code scans for vulnerability assessments ( https://www.owasp.org/index.php/Free_for_Open_Source_Application_Security_Tools )
Real time collaboration leaders include ( Gmail Zoom Slack Skype )
Jenkins for CICD
Youtube - Deploy Docker Microservices on Jenkins - 20 mins
Github API access for CICD integration
Github v3x API catalog
https://developer.github.com/v3/
This describes the resources that make up the official GitHub REST API v3. If you have any problems or requests, please contact GitHub Support.
- Current version
- Schema
- Authentication
- Parameters
- Root endpoint
- GraphQL global node IDs
- Client errors
- HTTP redirects
- HTTP verbs
- Hypermedia
- Pagination
- Rate limiting
- User agent required
- Conditional requests
- Cross origin resource sharing
- JSON-P callbacks
- Timezones
Github v3x API repo services
https://developer.github.com/v3/repos/
- List your repositories
- List user repositories
- List organization repositories
- List all public repositories
- Create
- Create repository using a repository template
- Get
- Edit
- List all topics for a repository
- Replace all topics for a repository
- Check if vulnerability alerts are enabled for a repository
- Enable vulnerability alerts
- Disable vulnerability alerts
- Enable automated security fixes
- Disable automated security fixes
- List contributors
- List languages
- List teams
- List tags
- Delete a repository
- Transfer a repository
- Create a repository dispatch event
Github v3x API Events
https://developer.github.com/v3/activity/
Activity
Serving up the "social" in Social Coding, the Activity APIs provide access to notifications, subscriptions, and timelines.
The Events API is a read-only interface to all the event types that power the various activity streams on GitHub.
List of Atom feeds available for the authenticated user.
Notifications of new comments are delivered to users. The Notifications API lets you view these notifications and mark them as read.
Repository Starring is a feature that lets users bookmark repositories. Stars are shown next to repositories to show an approximate level of interest. Stars have no effect on notifications or the activity feed.
Watching a Repository registers the user to receive notifications on new discussions, as well as events in the user's activity feed.
GIT Data v3x API
https://developer.github.com/v3/git/
Manage GIT data directly instead of using the standard object API's.
Comes with a risk of corrupting GIT data if done incorrectly.
The Git Database API gives you access to read and write raw Git objects to your Git database on GitHub and to list and update your references (branch heads and tags).
This basically allows you to reimplement a lot of Git functionality over our API - by creating raw objects directly into the database and updating branch references you could technically do just about anything that Git can do without having Git installed.
Git Database API functions will return a 409 Conflict
if the Git repository is empty or unavailable. An unavailable repository typically means GitHub is in the process of creating the repository. For an empty repository, you can use the Create a file endpoint to create content and initialize the repository so you can use the Git Database API. Contact GitHub Support if this response status persists.
For more information on the Git object database, please read the Git Internals chapter of the Pro Git book.
As an example, if you wanted to commit a change to a file in your repository, you would:
- Get the current commit object
- Retrieve the tree it points to
- Retrieve the content of the blob object that tree has for that particular file path
- Change the content somehow and post a new blob object with that new content, getting a blob SHA back
- Post a new tree object with that file path pointer replaced with your new blob SHA getting a tree SHA back
- Create a new commit object with the current commit SHA as the parent and the new tree SHA, getting a commit SHA back
- Update the reference of your branch to point to the new commit SHA
It might seem complex, but it's actually pretty simple when you understand the model and it opens up a ton of things you could potentially do with the API.
Process to Check Mergeability of Pull Requests
https://developer.github.com/v3/git/
Warning! Please do not depend on using Git directly or GET /repos/:owner/:repo/git/refs/:ref
for updates to merge
Git refs, because this content becomes outdated without warning.
A consuming API needs to explicitly request a pull request to create a test merge commit. A test merge commit is created when you view the pull request in the UI and the "Merge" button is displayed, or when you get, create, or edit a pull request using the REST API. Without this request, the merge
Git refs will fall out of date until the next time someone views the pull request.
If you are currently using polling methods that produce outdated merge
Git refs, then GitHub recommends using the following steps to get the latest changes from the base branch (usually master
):
- Receive the pull request webhook.
- Call
GET /repos/:owner/:repo/pulls/:pull_number
to start background job for creating the merge commit candidate. - Poll your repository using
GET /repos/:owner/:repo/pulls/:pull_number
to see if themergeable
attribute istrue
orfalse
. You can use Git directly orGET /repos/:owner/:repo/git/refs/:ref
for updates tomerge
Git refs only after performing the previous steps.
One Process to Rebase repos after a repo rename
Here is the process that I will be following for each repository:
- Use the new Github feature to rename default branch. This automatically re-targets PRs to "main" and updates branch protections rules.
- PR to update master references in CI pipelines, docs, etc
- Update default branch in Azure Pipelines
Once it is done for a repository, each developer that has a local fork will need to perform the following steps to update their local environment, push the main branch to their fork and associate with local main branch, and ensure local main is rebased on the upstream main branch:
git checkout master
git branch -m master main
git fetch origin
git push origin main
git branch -u origin/main main
git fetch upstream
git rebase upstream/main
The steps assume you are following the Github fork and upstream remote instructions here:
https://hyperledger-fabric.readthedocs.io/en/latest/github/github.html
Please let us know if you have any other suggestions or comments.
Bitbucket
Bitbucket intro
https://www.geeksforgeeks.org/introduction-to-bitbucket/?ref=rp
- Working on Git Bash
- Difference Between GitLab and GitHub
- Deploy Python Flask App on Heroku
- How to integrate Git Bash with Visual Studio Code?
- Setting up Sublime Text for C++ Competitive Programming Environment
- How to Upload Project on GitHub from Android Studio?
- Setting up a C++ Competitive Programming Environment
- Deleting a Local GitHub Repository
- How to Deploy a Basic Static HTML Website to Heroku?
- What is a GIT Repository?
- How to Upload a Project on Github?
- Working on Git for GUI
- How to Install, Configure and Use GIT on Ubuntu?
- Merge Strategies in Git
- Difference Between Git and GitHub
- Bare Repositories in Git
- How to Upload Project on GitHub from Jupyter Notebook?
- Difference Between GIT and SVN
- Jenkins and GIT Integration using SSH Key
- Difference Between Bitbucket and GitHub
- How to Clone Android Project from GitHub in Android Studio?
- How to Upload Project on GitHub from Pycharm?
- Using GitHub with SSH (Secure Shell)
- GIT | An Introduction to Github
- Working on BitBucket using Git
- Making a Github Bot
- How to Earn Money From GitHub?
- Using GitHub to host a free static website
- Git Features
- How to add a README to your GitHub profile?
Bitbucket Tutorial
geeksforgeeks--working-on-bitbucket-using-git
geeksforgeeks--working-on-bitbucket-using-git pdf
- Working on Git Bash
- Using Git on CommandLine
- Using Patches in Git
- Patch Operation in Git
- What is Collaboration in Git?
- Recovering Lost Commits in Git
- Working on BitBucket using Git
- Working on Git for GUI
- Pushing changes to a Git Repository
- Bare Repositories in Git
- Working with Git Repositories
- Git Features
- An Ultimate Guide to Git and Github
- GIT | An Introduction to Github
- What is a GIT Repository?
- Version Control Systems
- Centralized vs Distributed Version Control: Which One Should We Choose?
- Comparison – Centralized, Decentralized and Distributed Systems
- Difference between Centralized Database and Distributed Database
- Distributed Database System
- Advantages of Distributed database
- Functions of Distributed Database System
- Data Replication in DBMS
- Concurrency Control in DBMS
- Handling repositories with Git remote
- Difference Between GitLab and GitHub
- Deploy Python Flask App on Heroku
- How to integrate Git Bash with Visual Studio Code?
Potential Value Opportunities
Potential Challenges
Candidate Solutions
Step-by-step guide for Example
sample code block