DevOps Classroom Series – 26/Nov/2021

Git Remote

  • Fourth area of Git: Remote Repo Preview
  • To handle the centralization of work done by multiple people in your organization we will have a central Repository/Remote Repository Preview
  • The Remote Repository in Git are generally referred as Git Remote Server/Git Servers & these can be installed and maintained your organization or they can use cloud based Remote Repositories
  • Remote Repositories have majorly two additional features
    • daemon with some protocol to connect (https/ssh)
    • user management
  • Self Hosted Remote Repositories
    • Gitolite
    • Git lab Self Hosted
    • Bit Bucket Self Hosted
  • Cloud Hosted or Provider Hosted Remote Repositories
    • GitHub
    • Gitlab
    • BitBucket
    • Azure Source Repos
    • AWS Code Commit
  • Lets start understanding how the remote repositories can be working along with local repositories
  • Lets look at graph of the changes you have done Preview
  • Now lets create a remote repository in GitHub which is public Preview
  • The repository is hosted on using two protocols
  • We have create a github repo for understanding Preview
  • Now we need to send the commits from local repo to git hub
  • So to do this, we need to inform our local repository about a remote repository
git remote add '<name-of-remote>' '<url-of-remote>'
  • In git we generally use the name of remote as ‘origin’
git remote add origin ''


  • Now lets push the changes to the remote repository
git push <name-of-remote> <branch-to-push>
  • So our command would be git push origin master Preview Preview
  • When we connect with a remote repository, remote tracking branches will be created in your local system Preview Preview
  • Lets make one more change in the local repo and commit the changes Preview
  • Now when we want to push the changes to remote repository for a particular branch, the condition origin/master and the master in the remote server should be looking at same commit id. If that is not the case the push fails Preview
  • Now lets push the changes Preview Preview Preview
  • Now for user2 lets try to create a clone Preview
  • Now let user2 make a change and create a local commit Preview Preview
  • Now let user1 make the change and create a local commit Preview Preview
  • Now let user1 push the changes to the remote repository Preview
  • Now if the user2 pushes changes to remote repository they will fail as the user2 tracking branch is not pointing to same commit id as remote repository i.e. we donot have latest changes in our local repository Preview
  • To get the latest changes from remote repository into your local repo
    • Fetch the changes from remote repo to your tracking branch
    • merge the changes from tracking branch to local branch
  • Git pull command does both i.e (Git pull => git fetch + git merge) Preview
  • Now lets push Preview
  • Now lets make one commit for user 1 Preview
  • Now if we push from user1 it would fail Preview
  • If we use git pull then it will create an extra commit which user1 doesn’t like so he uses the following command git pull --rebase Preview Preview

Leave a Reply

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

About learningthoughtsadmin