0

I am new to github, and someone gave me a private repo to clone and try to make easy modification, but the repo had some bugs, and not the person has updated his repo and fixed all the bugs, the problem is that, I need to update the files I have to the recent repo.

I don't know the command, although I am thinking it would be withing a range of merge origin/master I still have not tried any command, because I am not sure, if that will end up messing the original repo. So, how do I update mine, without making any modifications to the recent repo?

The source I downloaded it from is something like this git@gitlab.company.com:mobile-site.git

I have cloned the above in c:/wamp/www/mobile-site/

How, can I get the recent repo? thanks

samayo
  • 16,163
  • 12
  • 91
  • 106
  • 1
    Quick tip: since you're new to Git, consider installing [TortoiseGit](http://code.google.com/p/tortoisegit/). It's only for Windows, but it's helped me a ton, since it shows what git commands it runs when you ask it to do something. For Windows you can also use http://windows.github.com/ , and for Mac you can use http://mac.github.com/ – Albert Iordache Sep 10 '13 at 11:09

1 Answers1

1

Basically, you need to pull from origin onto your local repository, in order to update the files you already have.

Usually a git pull origin master should do the trick.

If it does not, you must do git remote add origin git@gitlab.company.com:mobile-site.git and then follow this with git pull origin master.

git pull is essentially the equivalent of git fetch followed by git merge. Here are some links that might help you:

Albert Iordache
  • 409
  • 1
  • 5
  • 15
  • Thanks, but does `origin master` has to be the URL of origin/master or it is just usable like that? Because, I did the same thing and say n an error that said. `fatal: 'G:/mobile-site' does not appear to be a git repository. I don't even have drive `G:/` all is in `C:/wamp/www/mobile-site` – samayo Sep 10 '13 at 10:38
  • That's quite weird. By default, `git clone` will make sure that `origin` points to the URL you cloned from. Try doing `git remote remove origin`, and then re-add through what I wrote above. Lemme know how it works. :) – Albert Iordache Sep 10 '13 at 10:44
  • Well, I did the first time (`git remote remove origin`) nothing happened,(probably got executed) the second time, I tried the same command I got `error: could not remove config section 'remote.origin'` No files are removed though, and I am running this command from directory `c:/wamp/www/mobile-site` – samayo Sep 10 '13 at 10:55
  • I think it worked. I did gitpull and started downloading everything, it is saying now, `Please, commit your changes or stash them before you can merge`,`Aborting` Not sure, what that exactly means – samayo Sep 10 '13 at 10:59
  • Okay, do a `git stash` in order to save your current changes. Then do the pull again, and then do `git stash pop`. This will put your current changes on top of what you've pulled from the other person's repository. – Albert Iordache Sep 10 '13 at 11:00
  • Thanks, I did `git stash` then pulled it. all went nice, but when I did the third command, `git stash pop` it listed all the changes but at the end of line it said, `unable to refresh index` How do I refresh index? – samayo Sep 10 '13 at 11:03
  • That means that a change done by the other person conflicts with a change done by you before you pulled, and git cannot automatically figure out where to put the changes you guys did to the code. Your changes are still safe, but you need to merge them. Take a look at http://stackoverflow.com/questions/9739352/git-stash-pop-needs-merge-unable-to-refresh-index :) – Albert Iordache Sep 10 '13 at 11:06
  • thanks for all the help, thanks to you I know some commands now. – samayo Sep 10 '13 at 11:09