Closed zackmdavis closed 10 years ago
Question: how do I pull from this branch (as opposed to master -- to play with it before merging)? I tried: $ git remote add an_impulsive_branch https://github.com/zackmdavis/Finetooth/tree/an_impulsive_branch
followed by: $ git checkout -b my_impulsive_branch
then: $ git pull an_impulsive_branch my_impulsive branch
but that produces: /// Terminal Output /// fatal: 'an_impulsive_branch' does not appear to be a git repository fatal: Could not read from remote repository
Please make sure you have the correct access rights and the repository exists. ///
This site seemed to suggest that git clone was what I wanted, but when I tried it it didn't seem to do anything:
$ git clone origin fatal: repository 'origin' does not exist # WTF?! $ git clone https://github.com/zackmdavis/Finetooth Cloning into 'Finetooth'... [...] $ git branch master my_impulsive_branch profile_editing # local branch I created
(I was expecting it to create a local "an_impulsive_branch" branch, of course.)
Reading the aforementioned page again, it occurred to me that maybe I had misunderstood the semantics of git pull, and that $ git pull origin an_impulsive_branch would do the trick, but no:
/// Terminal Output /// [...] error: Your local changes to the following files would be overwritten by merge: [...] Please, commit your changes or stash them before you can merge. Aborting. /// Merge? But I'm not...oh, that's right -- I remember hearing that git pull was shorthand for something called git fetch followed by git merge...so maybe I merely want to "fetch":
$ git fetch origin an_impulsive_branch [output that looks like it worked (sorry, can't copy/paste from Git Bash terminal, and am tired of typing)]
But no:
$ git branch [same list of branches as before]
I guess I could go read about git stash now, since it suggested doing that, but...will that make git pull do what I want?
I guess I could go read about git stash now, since it suggested doing that, but...will that make git pull do what I want?
(Update: apparently so...)
Question: how do I pull from this branch (as opposed to master -- to play with it before merging)?
I normally do git fetch
(fetch all the new content from the remote
server, but don't change or create any local branches), followed by
git checkout the_new_remote_branch
(if I don't already have a local
branch with that name, Git infers that I want a new local branch
configured to "track" the branch with that name on the remote).
[remainder of comment]
git remote
commands are for managing which entire
copies-of-a-repository-elsewhere you can push to and pull
from, whereas git clone
gives you your own copy of a repository (and
sets the place you downloaded it from as the default remote with the
default name "origin"); you typically only need these commands when
setting stuff up for the first time.
git stash
just saves your current uncommitted changes away somewhere
that they can be retrieved from later, and returns your working files
to the state of the current commit ("HEAD").
@cookjw