简体   繁体   English

如何在我的本地git克隆回购之前判断github回购是否

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

My work group has a github repo that is just documentation. 我的工作组有一个github存储库,它只是文档。
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 告诉github上的工作组存储库是否已被修改
  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. 如果您的存储库位于远程存储库后面,则Git status将通知您。 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 fetch仅下载对远程存储库所做的更改; 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 status向您显示本地存储库文件处于哪个阶段(未注册,未修改,修改或暂存),并显示与远程存储库是否存在某些差异; git pull is similar to a shortcut to these command: git pull与这些命令的快捷方式类似:

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: 关于Git更多信息可以在这里阅读:

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 如果要查找本地分支和远程分支之间是否存在差异,请运行diff命令

# 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命令

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

To merge the changes into your branch use the git pull 要将更改合并到分支中,请使用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获取

    git status git状态

The fetch command fetches information about the remote repo, but it does not update your local working files. fetch命令可获取有关远程存储库的信息,但不会更新本地工作文件。 The status command will tell you if the remote branch is X commits ahead of your local branch. status命令将告诉您远程分支是否为X,它会在本地分支之前提交。

  1. To pull the changes to the local machine: 要将更改拉到本地计算机:

    git pull git pull

Git will automatically only grab changes. Git只会自动获取更改。 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. pull命令获取这些更改(如对数字1的回答一样),并将这些更改合并到本地文件中,因此您实际上将“看到”这些更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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