Search code examples
gitbranchgit-checkoutpull

'git pull origin master': will this affect my committed, not yet merged, changes?


Unfortunately I wasn't able to find the answer to my specific problem through research, so I am looking for some help. The answer may be out there, but I don't have a good enough understanding to determine whether it will help me in my current situation. I am relatively new to git, and I need to get the latest changes from the repository which I forked from.

Here is what I have done prior:

  1. I forked the repository to create a copy of my own.
  2. I cloned my copy to my machine using git clone.
  3. From my forked copy, I created a new branch to work off of, and committed some changes.
  4. I created a merge request to merge my branch with the main repo, but it has not been merged yet.

Some changes have been made to the main repo, and I have been asked to continue working on the branch which I requested to be merged. I now need to pull the code from the master of the main repo, and bring it into my branch so I can continue working with a project that is up to date.

I was told to do a 'git pull origin master', however, I notice that the origin (after doing git remote -v) is my copy of the repo. Now to my question: Would the 'git pull origin master' be the correct thing to do in order to get the most recent code from the main repo into my branch that is checked out (and not merged yet)?

Just a side note: I am currently in training, so this may not be how the process usually goes, but I just want to make sure I am doing things correctly. If you need any more information to answer the question, please let me know. Thanks.


Solution

  • Sounds like you want to do git pull remote_repo master where remote_repo is the name that appears when you do git remote -v for the remote repository.

    If the remote repository doesn't appear when doing git remote -v then you should add it git remote add upstream upstream_url you can choose whatever name, I like upstream.