Get a local copy of a GitHub repo, track changes and push updates back to the remote

后端 未结 4 905
眼角桃花
眼角桃花 2020-12-29 16:29

I have a repo on GitHub and I want to update it with changes made to the folder I pulled it from.

What are the steps, without jargon or short hand terms, a new Git u

相关标签:
4条回答
  • 2020-12-29 17:09

    You're working alone, I infer, so it is very simple.

    1) is done by "git clone" through SSH. The github website will give you the clone URL.
    2) Just work locally, that's what DVCS's are about :-) And "git commit" what you develop.
    3) You need to "git push" your branch to github. It will then be fetchable by other people.

    These are the basics, when you will get confident with this simplest workflow, you can learn many stuff that will suit your coding practices nicely, rewrite your history and lots of nice git stuff.
    And you will learn how to work with other people, merge, and rebase.

    0 讨论(0)
  • 2020-12-29 17:18

    At first you cd into the repository:

    cd My-Repository
    

    You add all the files you want to have in the commit:

    git add my-code
    

    You commit the changes:

    git commit -m "Commit-Message"
    

    And then you push the changes up to github (Be sure to clone it via SSH or HTTPS). When working with branches you have to replace „master“ with the correct branch.

    git push origin master
    
    0 讨论(0)
  • 2020-12-29 17:20

    Here is a short summary of what you need:

    1. Create a local version of the remote repository on my computer:

      git clone <remote-url>
      
    2. Start making and tracking changes to the local copy:

      # Add or modify some files.
      # Then add them to Git's staging area:
      git add <file1> <file2> <etc>
      
      # Commit the changes
      git clone -m "Your commit message"
      
    3. When you're done making changes, push them back to the remote repository.

      git push origin <branch>
      

      When you push to the remote repository, your changes may be rejected because there are new commits on the remote that you need to merge your work with, in which case you can

      git fetch origin
      
      git merge origin/branch
      # Or
      git rebase origin/branch
      

      to synchronize your local work with the new changes, then try pushing again. Avoid rebasing commits that are already shared with other people though, because it will force them to resynchronize their work with the rewritten commits (if your team is comfortable with this, then this is feasible).

    You Should Still Read the Pro Git Book

    Everything I've outlined above is just a short summary. I didn't even go into how to resolve merge conflicts.

    If you truly want to become proficient with Git, then I still highly recommend that you read the FREE online Pro Git book, in particular chapters 1-3, 6-6.5. There's even iPad, Kindle, and PDF versions that you can download for free.

    0 讨论(0)
  • 2020-12-29 17:26

    The most simple flow is this:

    # clone the repository (from github, for example)
    git clone git@github.com:username/reponame.git
    cd reponame    
    
    # edit some files
    
    # add them to the index
    git add file1.txt
    git add file2.gif
    
    # review your changes
    git status    
    
    # commit the changes
    git commit -m "Decription of my change"
    
    # push them back to the remote repository
    git push origin master
    

    This is the basic flow that should get you going. However, there's lots of resources for learning the basics of git, I highly recommend you go over them. Getting started is really not that difficult as it seems.

    0 讨论(0)
提交回复
热议问题