刚开始接触github,然后就使用git客户端来进行操作,遇到git pull时,总感觉有git fetch和git merge了,为何还要git pull呢?特意翻了git的帮助文档看了下。
git pull [options] [<repository> [<refspec>…]]
Fetch from and integrate with another repository or a local branch
从另一个仓库或者本地的分支获取并且合并到当前的分支中。
In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
默认情况,git pull 等于在git fetch 之后git merge FETCH_HEAD。
<repository> should be the name of a remote repository as passed to git-fetch(1). <refspec> can name an arbitrary remote ref (for example, the name of a tag) or even a collection of refs with corresponding remote-tracking branches (e.g., refs/heads/*:refs/remotes/origin/*), but usually it is the name of a branch in the remote repository.
repository必须是一个远程的仓库,refspec可以是一个远程仓库上的分支。
Update the remote-tracking branches for the repository you cloned from, then merge one of them into your current branch:
git pull origin
从先前克隆的远程仓库更新到本地分支
Merge into the current branch the remote branch next:
git pull origin next
合并远程仓库的的分支next到本地分支中
If you tried a pull which resulted in complex conflicts and would want to start over, you can recover with git reset
如果发现有很多冲突,可以利用git reset来撤销
相关:
git remote add origin git@github.com:ggwhsd/hello-world.git //连接远程github项目
git remote rm origin //删除远程,若上述报错,可以使用
git push -u origin master //将本地项目更新到github项目上去
转载于:https://blog.51cto.com/gugw9handsome/1625821