You can use “git pull” to retrieve the latest commits in a git branch that are not yet present in your local branch.
To see what changed after “git pull”, you should note the id of the latest commit before the pull request. After the pull request, you can issue “git diff” on the noted commit id and the newest commit id in the updated branch to get all the changes.
Let us see through a hands-on example.
The initial setup is as shown. “git log –oneline” command indicates that there are three commits. “git status” shows that there are two more commits that are not present in the local branch, and we should issue “git pull”.
Before issuing “git pull”, note down the latest commit id. Here, it is 42296d0.
~/repoone$ git log --oneline 42296d0 (HEAD -> main) Second commit in main 453424e This is first commit 2673111 Initial commit ~/repoone$ git status On branch main Your branch is behind 'origin/main' by 2 commits, and can be fast-forwarded. (use "git pull" to update your local branch) nothing to commit, working tree clean
We issued “git pull” to get the local branch updated.
~/repoone$ git pull Updating 42296d0..4632c0d Fast-forward dirtwo/.gitignore | 4 ++++ filefive | 0 filesix | 0 3 files changed, 4 insertions(+) create mode 100644 dirtwo/.gitignore create mode 100644 filefive create mode 100644 filesix
Use “git log –oneline” to see the list of commits and note down the latest commit ID; it is 4632c0d.
~/repoone$ git log --oneline 4632c0d (HEAD -> main, origin/maincopy, origin/main, origin/HEAD) Adding empty directory 908d6ac Third commit in main 42296d0 Second commit in main 453424e This is first commit 2673111 Initial commit
To know what all changed after “git pull”, issue “git diff” on the two commit ids, i.e., git diff 42296d0..4632c0d. You can see in the example shown that all the changes after the pull are listed.
~/repoone$ git diff 42296d0..4632c0d diff --git a/dirtwo/.gitignore b/dirtwo/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/dirtwo/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/filefive b/filefive new file mode 100644 index 0000000..e69de29 diff --git a/filesix b/filesix new file mode 100644 index 0000000..e69de29