Search code examples
pythongithubgit-clone

How to update personal cloned github?


I recently downloaded an open-source project from github into my server using

$ git clone www.github.com/project_url

Then I added comments and descriptions inside the multiple files here and there. When I went to the github repository of the original project github page, many of the files were updated. But I'm hesitating to clone again because I think it would just overwrite every local files to which I wrote many of the comments.

Is there anyway I can download up-to-date files in the github, but leave the comments that I added not being removed at the same time?


Solution

  • There are multiple strategies to go around this problem. A strategy is already explained. Another could be

    1. Commit your changes (git commit -am <message>)
    2. Do a git pull (git pull -r)
    3. Resolve conflicts if any

    Also, you can keep your changes separate in a separate branch. Here is what else can be done:

    1. Create a separate branch in your local repository (git checkout -b <branch-name>, eg. git checkout -b new-branch)
    2. commit changes in that new branch (git commit -am <message>)

    Either you can merge now from your new branch to the old branch

    1. git checkout old-branch; git merge new-branch.
    2. resolve conflicts if any

    OR

    1. Raise a Pull Request after resolving any conflicts if any