DevOps Classroom Series – 08/Jul/2021

Working with Remote git

  • Scenario: We will be simulating two developers working on git Preview
  • Configure username and email for the git users in linux and windows
git config --global user.name "your-username"
git config --global user.email "your-email"
  • On the linux machine lets use ssh to connect to git, for that we need to configure ssh keys in the remote repository
    • create ssh-key pair
    ssh-keygen
    
    Preview
    • Copy the public ssh-key to github ssh keys Preview Preview
    • clone the repo on the linux machine for developer 2 Preview
  • Developer 1 starts working on a feature f1001 in the v1.0 branch
    • commit the changes of developer 1
  • Developer 2 also starts working on feature f1002 in the v1.0 branch
    • commit the changes of developer 2
  • As of now the state of branches after developers have done local changes Preview
  • Now Developer 2 has pushed the changes to the remote repository Preview
  • In Git when we want to push the changes the remote-repository branch (which looks at latest commit ) the origin/branch should exactly match with the remote repository branch
  • Now Developer 1 wants to push the changes, this leads to error as origin/v1.0 is not matching the remote branch Preview
  • Now Developer 1 updates the local repo by using pull command, fixes the merge Preview
  • Now Developer 1 can push his changes Preview
  • Now Developer 2 starts working on feature f1003 Preview
  • When developer 2 pushes the changes he will get error as he needs to pull the changes. Developer 2 wants to pull the changes but he doesnot want a new merge commit to be created.
git pull --rebase

Preview

  • Now both developer 1 can get the changes using git pull Preview

Git Reset Hard vs mixed vs soft

Preview

Leave a Reply

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

About learningthoughtsadmin