Answers for "what does git pull do"

10

git pull hard

git reset --hard origin/master
Posted by: Guest on November-22-2019
1

how to pull the latest changes from git

Case 1: Don’t care about local changes

Solution 1: Get the latest code and reset the code

git fetch origin
git reset --hard origin/[tag/branch/commit-id usually: master]
Solution 2: Delete the folder and clone again :D

rm -rf [project_folder]
git clone [remote_repo]
Case 2: Care about local changes

Solution 1: no conflicts with new-online version

git fetch origin
git status
will report something like:

Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
Then get the latest version

git pull
Solution 2: conflicts with new-online version

git fetch origin
git status
will report something like:

error: Your local changes to the following files would be overwritten by merge:
    file_name
Please, commit your changes or stash them before you can merge.
Aborting
Commit your local changes

git add .
git commit -m ‘Commit msg’
Try to get the changes (will fail)

git pull
will report something like:

Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
Open the conflict file and fix the conflict. Then:

git add .
git commit -m ‘Fix conflicts’
git pull
will report something like:

Already up-to-date.
Posted by: Guest on September-17-2020
-1

how to pull from a branch in git

git pull origin other-branch
Posted by: Guest on October-27-2020
4

git pull

#Basic command, get changes of current branch to remote repo
git pull
#When working with others, I usually stash my local changes
#before pulling in order to avoid conflict commits.
git stash
git pull 
git stash pop #Reapply my local changes, eventually merge confl
Posted by: Guest on April-05-2020
1

git pull

git checkout new_feature
git pull <remote repo>
Posted by: Guest on March-20-2020

Browse Popular Code Answers by Language