Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (29.3k points)


What are the Git commands to do the following workflow?


I cloned from a repository and did some commits of my own to my local repository. In the meantime, my colleagues made commits to the remote repository. Now, I want to:

Check whether there are any new commits from other people on the remote repository, i.e. origin?

Say there were 3 new commits on the remote repository since my last pull, I would like to diff the remote repository's commits, i.e. HEAD~3 with HEAD~2, HEAD~2 with HEAD~1 and HEAD~1 with HEAD.

After knowing what changed remotely, I want to get the latest commits from the others.

My findings so far

For step 2: I know the caret notation HEAD^, HEAD^^, etc. and the tilde notation HEAD~2, HEAD~3, etc.

For step 3: That is, I guess, just a git pull.

1 Answer

0 votes
by (50.2k points)

For this you could use:

git fetch origin

This will update your remote branch to the latest version.

For a difference against remote you could use: 

git diff origin/master

And after checking that if you want to accept that changes you could use:

git merge origin/master 

Thus, you can see the diff between remote origin and git repository.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.2k users

Browse Categories