DevOps Classroomnotes 30/Apr/2022

Manipulating History Contd

Git rebase interactive

  • Using this interactive rebasing we can manipulate history
  • Lets create a repository and then have the following commits
    Preview

Activity 1: Need to fix the commit message

Preview
* Lets rewrite history in this case i would use HEAD~4

git rebase -i HEAD~4

Preview
* During interactive rebase most common actions which we perform are
* pick => add the commit during the rebase as it is
* squash => meld this commit into previous (combining two commits into one commit )
* edit: stops and edits the commit
* drop: removes the commit
* reword: change the commit message
* Now since we need to change the commit message
Preview
Preview
Preview
Preview

Activity 2: Lets change the typo in the first commit contents

  • typo:
    Preview
  • So lets rebase interactively git rebase -i HEAD~4
    Preview
    Preview
    Preview
    Preview
    Preview

Activity 3: Lets combine the second and third commit into one commit

  • History:
    Preview
  • Command would be git rebase -i HEAD~3
    Preview
    Preview

Activity 4: Lets drop the fourth commit

  • History
    Preview
  • command git rebase -i HEAD~1
    Preview
    Preview

Exercise:

  • Create a repository and ensure you have 3 commits
first
second
third
  • Do the rebasing to
    • combine second and third commit as one commit
    • change the commit message of first commit to “Primary Commit”
  • solution:
    Preview
    Preview

Collaboration in Git

  • When we work on code for an application, there will be multiple developers working on the source code, so working in local repository is not an option.
  • We need a connectivity with some Git Server (git + daemon (connectivity and user management))
  • Fourth Area of git
    Preview
  • Lets create the accounts in the following Hosted Git Servers

Public vs Private Repositories

  • Most of hosted repositories gives two options
    • Public Repository:
      • Every one can read the contents (source code)
      • This is apt for open source.
      • Generally for others to contribute we have two options
        • providing write access
        • pull requests
    • Private Repository
      • Read permissions/write permissions will be given to dedicated users
      • Apt for Enterprise Users.

Authentication to Remote Git Repositories

  • Using Personal Authentication token
  • Using an SSH key (* my favorite)
  • Using your Hosted Git password and username (2-factor authentication)

Creating a keypair

  • Execute ssh-keygen
    Preview

Activity 1: Make your local repository sync with Remote Repository

  • You are first person to create this project, so you created locally, Now you need to make it available to other developers
  • Git Authentication Mechanisms for Remote Repositories
  • Create a Remote Repository:
    • GitHub:
      Preview
      Preview
    • BitBucket:
      Preview
      Preview
    • Azure Source Repos: Create a repository as shown in the class
  • Every repository will have a url
  • To add a remote to your local repository git remote add <remote-name> <remote-url>
  • The default remote-name is origin
  • Lets add the remote for github
    Preview
    Preview
  • To send all of the commits from local to remote we use git push <remote-name> <branch>
    Preview
    Preview
    Preview
    Preview
  • Remote for bitbucket
    Preview
    Preview
  • Remote for Azure Source Repos:
    Preview
  • Sending one more branch
    Preview
  • Git tries to maintain a remote branch for every branch pushed into remote repository
    Preview

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube