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

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

What steps, without jargon or short hands, should a new Git user take from the moment they have a cd directory ?

Including how to track local changes made to any files, and then how to send these changes and updates back to the remote repository.

+4
source share
4 answers

The easiest thread:

 # 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 main thread that should catch you. However, lots of resources for learning the basics of git, I highly recommend you go through them. Getting started is really not as difficult as it seems.

+9
source

You work alone, I conclude, so it's very simple.

1) Run using git clone "via SSH. The github site will provide you with a cloning URL.
2) Just work locally, what about DVCS :-) And "git commit" is what you are developing.
3) You need to "git push" your branch on github. Then it will be available to other people.

These are the basics, when you are confident in this simplest workflow, you can learn a lot of things that will fit your coding rules well, rewrite your history and a lot of nice git things.
And you will learn how to work with other people, integrate and reinstall.

+3
source

First you write cd to the repository:

 cd My-Repository 

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

 git add my-code 

You make changes:

 git commit -m "Commit-Message" 

And then you push the changes to github (be sure to copy them using SSH or HTTPS). When working with branches, you must replace "master" with the correct branch.

 git push origin master 
+2
source

Here is a quick overview of what you need:

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

     git clone <remote-url> 
  • Start creating and tracking changes to your local copy:

     # Add or modify some files. # Then add them to Git staging area: git add <file1> <file2> <etc> # Commit the changes git clone -m "Your commit message" 
  • When you are finished making changes, revert them back to the remote repository.

     git push origin <branch> 

    When you click on the remote repository, your changes may be rejected, because there are new commits on the remote control with which you must combine your work, in which case you can

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

    to synchronize your local work with new changes, then try again. Avoid resetting commits that are already available to other users, but because this will cause them to re-synchronize their work with overwritten commits (if your team arranges this, then it is possible).

You should read the Pro Git Book.

All that I have stated above is just a brief summary . I did not even discuss how to resolve merge conflicts.

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

+2
source

Source: https://habr.com/ru/post/1392199/


All Articles