configure git on personal linux box

Developers , those want to use git can map linux virtual machine to github. In this way dev can port the code to github. Its easy to maintain the repository as well.

  1. Create a account on github.com
  2. After creating the account ,create a repository for yourself.
  3. SSH to your linux box and generate rsa key
    • ssh-keygen -t rsa -C “<emailid>
      copy the public key from .ssh/<>.pub to git
  4. Copy the public key to github
    • git3
  5. Commands to add file to new repository
    • git config –global user.email “<email id>”

      git clone git@github.com:<username>/mycode.git
      Cloning into ‘mycode’…
      remote: Counting objects: 3, done.
      remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
      Receiving objects: 100% (3/3), done.
      Checking connectivity… done.

      root [ ~ ]# cd mycode
      root [ ~/mycode ]# git add README.md
      root [ ~/mycode ]# git commit -m “add README.md”
      On branch master
      Your branch is up-to-date with ‘origin/master’.
      nothing to commit, working directory clean

      root [ ~/mycode ]# git push -u origin master
      Warning: Permanently added the RSA host key for IP address ‘192.30.252.129’ to the list of known hosts.
      Branch master set up to track remote branch master from origin.
      Everything up-to-date

    • Screenshot from github
    • git1
  6. Commands to add file to existing repository
    • cd <existing folder>

      root [ / ]# cd root/mycode/
      root [ ~/mycode ]# ls
      README.md
      root [ ~/mycode ]# git init
      Reinitialized existing Git repository in /root/mycode/.git/

      root [ ~/mycode ]# git add README1.md
      root [ ~/mycode ]# git commit README1.md

      [master 86ccf2f] new file: README1.md
      1 file changed, 0 insertions(+), 0 deletions(-)
      create mode 100644 README1.md

      root [ ~/mycode ]# git push -u origin master
      Counting objects: 3, done.
      Compressing objects: 100% (2/2), done.
      Writing objects: 100% (3/3), 278 bytes | 0 bytes/s, done.
      Total 3 (delta 0), reused 0 (delta 0)
      To git@github.com:amit23comp/mycode.git
      fc752b5..86ccf2f master -> master
      Branch master set up to track remote branch master from origin

    • git2