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

Activity 1: Need to fix the commit message


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

git rebase -i HEAD~4


* 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



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

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




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

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

Activity 4: Lets drop the fourth commit

  • History
  • command git rebase -i HEAD~1

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:

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
  • 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

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:

    • BitBucket:

    • 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

  • To send all of the commits from local to remote we use git push <remote-name> <branch>



  • Remote for bitbucket

  • Remote for Azure Source Repos:
  • Sending one more branch
  • Git tries to maintain a remote branch for every branch pushed into remote repository
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Exit mobile version
%%footer%%