简体   繁体   中英

How to tell if github repo ahead of my local git cloned repo

My work group has a github repo that is just documentation.
I clone that repo to have it local for off line work.
I do not change it or branch it. It gets updated but not branched.

What command do I use to

  1. tell if the work group repo on github has been modified
  2. pull just the changes to my local machine?

You can use:

git fetch
git status

to check if there are some updates of your remote repository. Git status will notify you if your repository is behind the remote repository. If you want to get that changes you have to use this command:

git pull

Note: git fetch download only the changes made to the remote repository; git status show to you in which phase the files of your local repository are (unregistered, unmodified, modified or staged) and show if there are some differences with the remote repository; git pull is similar to a shortcut to these command:

git fetch
git merge

ie it will download remote repository changes and then updates your local file (it will do a fast-forward update if you don't modify your local files).

More information about Git can be read here:

I hope this could help you.

If you want to find out if there are differences between your local branch and the remote branch run a diff command

# display changes between local branch to remote
git diff master origin/master

To update all the content of your repository use the fetch command

# Fetch all changes from the remote 
git fetch --all --prune

To merge the changes into your branch use the git pull

# merge the changes from the remote to my branch
# git pull is a combination of 2 commands. fetch + merge
# so this single command will fetch (bring) and add (merge) the changes
# made on the remote branch into your branch
git pull origin master
  1. To tell if the remote repo has been modified do the following:

    git fetch

    git status

The fetch command fetches information about the remote repo, but it does not update your local working files. The status command will tell you if the remote branch is X commits ahead of your local branch.

  1. To pull the changes to the local machine:

    git pull

Git will automatically only grab changes. The pull command fetches those changes - as in the answer to number 1 - and also merge those changes into to your local files, so you'll actually "see" the changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM