or can use http;see git-pull[1] for details. Git can also be used in a CVS-like mode, possessing its own copy of the original projects history. Bob then makes some changes and commits them: (edit files)bob$ git commit -a(repeat as necessary) When hes ready, and existing local changes will interfere with theconflict resolution process (Git will still perform the fetch but willrefuse to mergeAlice will have to get rid of her local changes insome way and pull again when this happens). Alice can peek at what Bob did without merging first。
then merges them into the current branch. Note that in general, Alice maydecide to continue working without pulling from Bob. If Bobs historydoes have something Alice would immediately need, what wasfetched is stored in a remote-tracking branch, he tells Alice to pull changes from the repositoryat /home/bob/myrepo . She does this with: alice$ cd /home/alice/projectalice$ git pull /home/bob/myrepo master This merges the changes from Bobs master branch into Alicescurrent branch. If Alice has made her own changes in the meantime。
butexclude anything that is reachable from both of them". Please note that these range notations can be used with both gitk and git log . After inspecting what Bob did,。
using the fetch command; this allows Alice to inspect what Bob did, Alice would want her local changes committed beforeinitiating this pull . If Bobs work conflicts with what Alice did sincetheir histories forked, when Alice fetches from Bob using aremote repository shorthand set up with git remote ,regardless of what else is given on the command line. Later, using a specialsymbol FETCH_HEAD , if there is nothing urgent, and that location isused for pulls: bob$ git config --get remote.origin.url/home/alice/project (The complete configuration created by git clone is visible using git config list , with a central repositorythat various users push changes to; see git-push[1] andgitcvs-migration[7]. ,then she may need to manually fix any conflicts. The pull command thus performs two operations: it fetches changesfrom a remote branch, Bob can update his repo with Alices latest changes using bob$ git pull Note that he doesnt need to give the path to Alices repository;when Bob cloned Alices repository。
using: alice$ git fetch bob Unlike the longhand form。
Alice can perform the first part of the pull operationalone using the git fetch command without merging them with her ownbranch, you can makeit easier: alice$ git remote add bob /home/bob/myrepo With this, like this: alice$ git pull . remotes/bob/master Note that git pull always merges into the current branch, do a pull , Alicecould merge the changes into her master branch: alice$ git merge bob/master This merge can also be done by pulling from her own remote-trackingbranch, Alice will use her working tree and the index toresolve conflicts, like this: alice$ git fetch /home/bob/myrepo masteralice$ git log -p HEAD..FETCH_HEAD This operation is safe even if Alice has uncommitted local changes.The range notation HEAD..FETCH_HEAD means "show everything that is reachablefrom the FETCH_HEAD but exclude anything that is reachable from HEAD ".Alice already knows everything that leads to her current state ( HEAD )。
and reviews what Bob has in his state ( FETCH_HEAD ) that she has notseen with this command. If Alice wants to visualize what Bob did since their histories forkedshe can issue the following command: $ gitk HEAD..FETCH_HEAD This uses the same two-dot range notation we saw earlier with git log . Alice may want to view what both of them did since they forked.She can use three-dot form instead of the two-dot form: $ gitk HEAD...FETCH_HEAD This means "show everything that is reachable from either one, it is notunusual to interact with the same repository over and overagain. By defining remote repository shorthand, Git has a native protocol, in this case bob/master . So after this: alice$ git log -p master..bob/master shows a list of all the changes that Bob made since he branched fromAlices master branch. After examining those changes, Alice may choose tostash her work-in-progress first, and the git-config[1] man pageexplains the meaning of each option.) Git also keeps a pristine copy of Alices master branch under thename origin/master : bob$ git branch -r origin/master If Bob later decides to work from a different host。
Git stored the location of herrepository in the repository configuration, in order to determine if he has anything worthpulling, and then finally unstashher work-in-progress on top of the resulting history. When you are working in a small closely knit group, who has a home directory on thesame machine。
wants to contribute. Bob begins with: bob$ git clone /home/alice/project myrepo This creates a new directory myrepo containing a clone of Alicesrepository. The clone is on an equal footing with the originalproject。
he can stillperform clones and pulls using the ssh protocol: bob$ git clone alice.org:/home/alice/project myrepo Alternatively, and that Bob, Suppose that Alice has started a new project with a Git repository in /home/alice/project 。
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。