Sunday 21 July 2019

Git: Pull the data from remote branch


'git pull origin HEAD' command pulls the data from remote branch.

Let’s see it with an example.

Step 1: Cline any git repository by executing below command.
git clone {repository_url}

$git clone https://github.com/harikrishna553/gitHelloWorld.git
Cloning into 'gitHelloWorld'...
remote: Enumerating objects: 26, done.
remote: Counting objects: 100% (26/26), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 26 (delta 3), reused 16 (delta 2), pack-reused 0
Unpacking objects: 100% (26/26), done.


Step 2: Navigate to the repository root directory and execute 'git status' command.
$cd gitHelloWorld/
$
$git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean


Step 3: Create new file in github remote branch.


Currently, there are four files. Let me add new file ‘dempapp.txt’.



Step 4: come to your local terminal and execute ‘git pull origin HEAD’ command to pull the changes from remote origin.

$git pull origin HEAD
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/harikrishna553/gitHelloWorld
 * branch            HEAD       -> FETCH_HEAD
Updating 3f857de..53ed4ca
Fast-forward
 demoapp.txt | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 demoapp.txt
$
$ls
README.md  demoapp.txt  tempFile1.txt  tempFile4_copy.txt welcome.txt



Previous                                                    Next                                                    Home

No comments:

Post a Comment