Followers

Git - Sync Local Repo with Github Repo(clone,fetch,merge,pull)

 git clone command This command downloads the copy of a Github repository to the local system. Example: There is a new developer who joined ...

 git clone command

This command downloads the copy of a Github repository to the local system.

Example:

There is a new developer who joined the project and he needs the latest code for the project. In this case, he can use the git clone command to download the latest repository.

        git clone <<HTTPS or SSH URL of Github Repo>>

After running the above command. there will be a directory get created with the same name as your Github repository name and you will find that this local repository has all the commits which are available on the Github repo. 

git fetch and merge command

fetch and merge commands are used to sync the data between local and remote repositories.

Example

Step1: Add a new file (github.java) to the Github repository.

Step 2: On-Command terminal run below command

            git fetch 

            git merge origin main

Step 3: Verify that the github.java file is available in the local Repo.

git pull command

This command is a combination git fetch and git merge command

git pull origin main --no-rebase

Example

Step 1: Let's create a file in the remote repo [Github](remote.java)

Step 2: Go to the local repository and add a file say main.java and commit this file to the local repo.

Step 3: Push commit changes to the remote repo.

           git push origin main

It will reject the push because the local repo is not in sync with the remote repo. remote.java file is missing in the local repo.

Step 4: To resolve this issue you first need to pull the changes and then push the changes to the remote repo.

              git pull --no-rebase

             git push origin main

            











COMMENTS

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Git - Sync Local Repo with Github Repo(clone,fetch,merge,pull)
Git - Sync Local Repo with Github Repo(clone,fetch,merge,pull)
DevOpsWorld
https://www.devopsworld.co.in/2022/04/git-sync-local-repo-with-github.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/04/git-sync-local-repo-with-github.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content