Fetch and Pull

<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" width="40px" /> There are 2 options to get changes on the repository from remote branch in GitHub.

Untitled

What it Fetch and Pull?

<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" width="40px" /> Fetch:

<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" width="40px" /> Pull

Git Fetch and Pull

<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" width="40px" /> Fetch and Pull We will see it in the terminal how git fetch vs git pull.

Practice


Untitled

Untitled

Untitled

Get Fetch

C:\\Users\\60115\\Documents\\Study\\Business Intelligence,
 D Intelligence Analyst\\Python\\Python-Learning>git fetch 
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 1.01 KiB | 37.00 KiB/s, done.
From <https://github.com/24434Accept/learning_push>      
   5611b23..03c5af9  main       -> origin/main

Check on Git Log

Untitled

Git Checkout

C:\\Users\\60115\\Documents\\Study\\Business Intelligence, Data Scientist, Data Analyst and Data Engineers\\Business Intelligence Analyst\\Python\\Python-Learning>git checko
ut origin/main
Note: switching to 'origin/main'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 03c5af9 Create addfromgithub.txt
M       learning_git/Fundamental-Python-Learning

Git switch

C:\\Users\\60115\\Documents\\Study\\Business Intelligence, Data Scientist, Data Analyst and Data Engineers\\Business Intelligence Analyst\\Python\\Python-Learning>git switch main
Previous HEAD position was 03c5af9 Create addfromgithub.txt
Switched to branch 'main'
M       learning_git/Fundamental-Python-Learning
Your branch is behind 'origin/main' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Git pull.

C:\\Users\\60115\\Documents\\Study\\Business Intelligence, Data Scientist, Data Analyst and Data Engineers\\Business Intelligence Analyst\\Python\\Python-Learning>git pull
Updating 5611b23..03c5af9
Fast-forward
 addfromgithub.txt | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 addfromgithub.txt

Screenshot 2024-02-15 091921.png

<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/2ba07339-dd53-47ac-b00d-c83e7722c42d/b39e600d-15ce-44a6-b5ce-eb6490d84e29/Colorful_Illustrative_Young_Male_Avatar_(1).png" width="40px" /> Git Fetch and Git Pull

</aside>