Going backward – publishing a local repository to GitHub

Commonly, you will find yourself needing to put your local repository on a shared place where someone else can look at your work; in this section, we will learn how to achieve this purpose.

Create a new local repository to publish, following these simple steps:

  1. Go to our local repositories folder.
  2. Create a new HelloWorld folder.
  3. In it place a new repository, as we did in first chapter.

 

  1. Add a new README.md file and commit it:
      [19] ~
      $ mkdir HelloWorld

      [20] ~
      $ cd HelloWorld/

      [21] ~/HelloWorld
      $ git init
      Initialized empty Git repository in C:/Users/san/Google 
Drive/Packt/PortableGit/home/HelloWorld/.git/
[22] ~/HelloWorld (master) $ echo "Hello World!" >> README.md [23] ~/HelloWorld (master) $ git add README.md [24] ~/HelloWorld (master) $ git config user.name "Ferdinando Santacroce" [25] ~/HelloWorld (master) $ git config user.email "[email protected]" [26] ~/HelloWorld (master) $ git commit -m "First commit" [master (root-commit) 5b41441] First commit 1 file changed, 1 insertion(+) create mode 100644 README.md [27] ~/HelloWorld (master)

Now, create the GitHub repository as we did previously; this time leave it empty. Don't initialize it with a readme file; we already have one in our local repository. The following is a screenshot taken directly from the GitHub repository creation page:

At this point, we are ready to publish our local repository on GitHub or, even better, to add a remote to it.

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

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