DevOps Classroom Series 15/Dec/2019 – Git Remote

Remote Repository

  • Remote Repository is git on other node (generally) Preview
  • Any node can host remote repositories. There are many softwares/platforms which can help us.
    • Softwares:
      • Gitolite
      • Git-Lab (Hosted)
    • Platforms
      • GitHub
      • BitBucket
      • Code Commit (AWS)
      • Azure Git Repos

Remote Repository Scenarios

  • Create a Local Repo first and push the changes to Remote Repository
  • Clone the Local Repo using Remote Repository Preview

Exercise on Remote Repository

  • Create a Remote Repository for Local Repository (Ecommerce app)
    git remote add <name-of-remote> <url>
    git remote add origin https://github.com/GitPracticeRepo/ecommerceapp.git
    
    • Push the changes to Remote Repository
    git push <name-of-the-remote> <branch-name>
    git push origin master
    
    • Lets push other branches
    git push origin sprint-1
    git push origin sprint-2
    
  • Clone a Local Repository from existing remote repository
    git clone <url>
    git clone https://github.com/GitPracticeRepo/AnsibleSamples.git
    

How the Remote is Handled

  • Whenever a Remote Repo is added, new branches gets created in Local Repository. <Remote-name>/<branch-name> will be the name for the remote branch.

  • Sending the changes from local to Remote is Push

  • Getting the latest changes from Remote to local is Pull (Fetch + Merge)

Changing Hisory of commits

  • Use Interactive Rebasing.

Cherry-Pick

  • To pick individual/sequence of commit(s) from one branch to other use cherry-pick
  • Refer Here

Bare Repositories

  • Git repositiries with only .git folders
  • Generally used on servers and also used for taking backup
git clone --bare <url>

One local Git Repo with multiple Remote Repos

git clone <url>
# a remote called as origin gets created
git remote add <other-repo-name> <other-repo-url>

Topics to be covered

  • Git Communication Protocols
  • Git Stash
  • Git Tags
  • Git Branching Strategy
  • Git Reflog
  • Git config
  • Git Hooks/WebHooks

Exercises

  • Demonstrate Fast-Forward
  • Demonstrate Merge
  • Demonstrate Rebase
  • Remove 3 commits from histroy
  • Combine 2 commits into one
  • Get one commit from one branch to other
  • Demonstrate Merge-Conflict

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner