Uploading modifications to remotes

So, let's try to edit the README.md file and upload modifications to GitHub:

  1. Edit the README.md file using your preferred editor, adding, for example, a new sentence.
  2. Add it to the index and then commit.
  3. Put your commit on the remote repository using the git push command.

But firstly, set the user and email this time, so Git will not output the message we have seen in the previous chapters:

[4] ~/Cookbook (master)
$ git config user.name "Ferdinando Santacroce"

[5] ~/Cookbook (master)
$ git config user.email "[email protected]"

[6] ~/Cookbook (master)
$ vim README.md

Add a sentence then save and close the editor.

[7] ~/Cookbook (master)
$ git add README.md

[8] ~/Cookbook (master)
$ git commit -m "Add a sentence to readme"
[master 41bdbe6] Add a sentence to readme
 1 file changed, 2 insertions(+)
  

Now, try to type git push and press ENTER, without specifying anything else:

[9] ~/Cookbook (master)
$ git push

Here, in my Windows 10 workstation, this window appears:

This is the Git Credential Manager; it allows you to set credentials on your Windows machine. If you are on Linux or macOS, the situation may be different, but the underlying concept is the same: we have to give Git the credentials in order to access the remote GitHub repository; they will then be stored to our system.

Input your credentials, and then press the Login button; after that, Git continues with:

[10] ~/Cookbook (master)
$ git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 328 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/fsantacroce/Cookbook.git
   e1e7236..41bdbe6  master -> master
  

The git push command allows you to upload local work to a configured remote location; in this case, a remote GitHub repository, as you can see in the following screenshot:

There are a few more things we need know about pushing; we can begin to understand the message Git gave us just after we ran the git push command.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.171.20