Download and update changes

Merge and Fetch

Merge and fetch are the command for git to update your project version from the repository. This command is used when your commit is behind the repository commit. This means you are not updated with the latest repository source.

Fetching source

$ git fetch origin
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://bitbucket.org/aj3sh/myrepository
   ab3bd2f..39b72a0  master     -> origin/master

Getting different between the local and remote repository

-In remote repository 2.txt => "My name is Ajesh sen thapa"

-In local repository 2.txt => "2.txt"

$ git diff origin/master
diff --git a/2.txt b/2.txt
index 476ea7c..85d3d43 100644
--- a/2.txt
+++ b/2.txt
@@ -1 +1 @@
-My name is Ajesh sen thapa
\ No newline at end of file
+2.txt
\ No newline at end of file

Merging the source files

$ git merge origin/master
Updating ab3bd2f..39b72a0
Fast-forward
 2.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Pull command, Automatic fetch and merge

$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://bitbucket.org/aj3sh/myrepository
 * branch            master     -> FETCH_HEAD
   ef60bbc..007c747  master     -> origin/master
Updating 39b72a0..007c747
Fast-forward
 2.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


You must login to comment

No comment yet


  • Online: 3
    Registered users: 7
    Unique visitors: 804
    Total hits: 10622