-1

A couple of weeks ago I cloned a repository to my local computer. I added some code to some of the files. Recently, there were updates to the repository that I want to pull. However, I want to save my progress by pushing to my own repo, but when I do this I create submodules instead of actual folders in git. How can I save my progress before pulling from the updated repo?

  • you need to fork the repo to your github account then clone that repo to your local system and then you can push to that forked repo in your account, You won't be able to directly push to that user's repo, you have to make a pull request for that. – Arpit Solanki Jun 14 '17 at 20:05

1 Answers1

3

You probably want to add a git remote to your local copy and push there:

$ git remote add alexyang https://github.com/alexyang/myrepo
$ git push alexyang master

In this example alexyang is an arbitrary name that will be how you refer to the repository (analogous to "origin", essentially a nickname for the full repo url). https://github.com/alexyang/myrepo is the repo url. master could of course be replaced with whatever branch you want to push.

Once you've committed & pushed your changes to your repo, you can then fetch from the original repo:

$ git fetch origin

And merge in those changes, or continue how you see fit. You will now have 2 references to remote branches, probably named origin/master and alexyang/master.

Alex B
  • 1,438
  • 13
  • 17
  • Thanks for the quick response. I added a git remote to my local copy, but when I add all the folders, commit, and push, my repository has only the submodules even though I expect to have folders. For example, if I had the folder named "cars" on my computer, after pushing, github shows that it is a submodule not a folder. – alex yang Jun 14 '17 at 22:09
  • The only thing I can think is that empty folders are not tracked by git. You'd have to add an empty file (named anything, .gitkeep is common) to keep the folder. What do you mean by submodule? Unless you have a .gitmodules file, it is unlikely that you actually have true git submodules happening in your repo. Is that the case? – Alex B Jun 14 '17 at 22:52
  • Github shows two grey overlapping folder icons next to the name of my folder. I checked and I don't have a .gitmodules file. – alex yang Jun 15 '17 at 17:41
  • Not entirely sure but check out this answer which might explain the meaning of the gray icon: https://stackoverflow.com/questions/19584255/what-does-a-grey-icon-in-remote-github-mean – Alex B Jun 16 '17 at 07:19