-1

Sorry. I'm still confused after reading the git docs. I first did:

$[home/myname]git clone git@bitbucket.org/.../nlp.git

It created 'nlp' directory under home/myname. Then I wrote lots of code under

$[/home/myname/nlp/.../myapp/]

Now I need to pull the latest nlp. Do I do it under my home directory as

$[home/myname]git pull git@bitbucket.org/.../nlp.git

Will it affect the codes I wrote in 'myapp'? Thanks for any help!

  • you need to cd into the cloned directory, in your case `nlp` or `nlp.git`, and then run any git commands in there. git clone is the only exception that needs to be done from the parent directory. – Pavan Yalamanchili Oct 19 '16 at 15:58
  • Possible duplicate of [Updating a local repository with changes from a Github repository](http://stackoverflow.com/questions/1443210/updating-a-local-repository-with-changes-from-a-github-repository) – Joe Oct 19 '16 at 15:59
  • @Joe: I'm not seeing that as a duplicate. – Makoto Oct 19 '16 at 16:00
  • Thanks! Will the code I wrote in 'myapp' be affected by doing 'git pull'. I want to make sure they won't disappear or be merged. – user2607925 Oct 19 '16 at 16:10

1 Answers1

1

You run git pull in the same directory as your repository, so in this case, it would mean running it in your nlp directory. If you attempted to do it in a non-Git directory, you would get a helpful error message:

fatal: Not a git repository (or any parent up to mount point /home/<user>)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Attempting to pull new code from upstream can impact your code if you're working directly on a branch which has new code on it. To mitigate this issue, it's advised to create a local branch for yourself, then pull down the latest copy from master, then merge that master branch into your local branch and deal with any conflicts.

Makoto
  • 104,088
  • 27
  • 192
  • 230
  • As hinted at in the error message here, you can also run `git pull` from a *subdirectory* of `nlp`, such as `/home/myname/nlp/.../myapp/` – 8bittree Oct 19 '16 at 18:06
  • @8bittree: You're absolutely right, but my preference is to be in the top directory since I usually do `git pull` and `git add .` like it's second nature, and `git add .` won't work if you're in a subdirectory with no changes. – Makoto Oct 19 '16 at 18:06
  • True, but I figured it might be helpful for people to know that it's an option. – 8bittree Oct 19 '16 at 18:08