GitHub – Command Line – Processing

GitHub – Command Line – Processing

Once again returning to Mr. Hunt’s home work “Ghost Who Codes: How Anonymity is Killing Your Programming Career”.

I wanted to share a SQL Lab Experiment with others that can help me.  Currently, I have the Transact SQL code sprinkled in WordPress postings.  To consolidate those SQL bits in a few easy to access files, I have posted those files in a free, publicly available GitHub repository.

My current desktop is a Mac Laptop. And, thankfully there’s a Git Command Line toolset for the Mac OS X.

In an earlier posting, I documented the steps to install the Command Line Toolset on a Mac OSX (https://danieladeniji.wordpress.com/2013/04/26/technical-github-installation-on-mac-osx/).

So needed to share these files and post it to GitHub.

The Git Hub repository is https://github.com/DanielAdeniji/MSSQLTableSpoolPartitionIndexUnaligned

Here are the steps (to post files from my local desktop to the GitHub repository):

  • Start a Terminal Mode Session
  • Change Folder to Source code Folder (cd <source-code-folder>)
  • Create Git Repository (git init)
  • Add files to Git (git add)
  • Commit Changes locally (git commit)
  • Add Remote Repository (git remote add origin)
  • Replicate local changes to remote repository (git push origin master)

Processing

Start Terminal Mode

Change Folder

Syntax:

cd <folder>

Sample:

    cd /Users/dadeniji/Documents/TableSpool/PartitionIndexUnAligned

Create Git Repository

To prepare a folder for Git, issue the “git init” command
Syntax:

git init

Output:

Initialized empty Git repository in /Users/dadeniji/Documents/TableSpool/PartitionIndexUnAligned

Add Files

Add specific files (*.sql)
Syntax:

git add <file-name>

Output:


git add *.sql

git - add - sql

Add specific files (*.png)
Syntax:

    git add <file-name>

Output:

    git add *.png

git - add - png

Commit

Commit changes

To commit the changes locally issue the “git commit” command.

Syntax:

    git commit

Output:
— commit changes (editor opened prompting for a comment)

    git commit

Output:

    -- commit changes and attach a comment
    git commit -m "commit changes"

 

git - commit

Git – Remote Add origin

To bind our local folder to its corresponding GIT Folder, we need to get the URL to the specific repository.

Steps:

  • Launch Browser
  • Connect to your repository Tab
    https://github.com/<Username&gt;?tab=repositories (Syntax)
    https://github.com/DanielAdeniji?tab=repositories (Ours)
  • Select the corresponding repository
  • Click the repository link
  • The repository window appears
  • Access the “Code” Tab
  • Select the protocol you want; in our case SSH
  • Copy the URL; in our case for the MSSQLTableSpoolPartitionIndexUnaligned repository the URL will be git@github.com:DanielAdeniji/MSSQLTableSpoolPartitionIndexUnaligned.git

Git Hub – Repository

github - Repositories

URL – HTTP/SSH

github - repository - MSSSQLTableSpool - SSH

Syntax:

   git remote add origin 

Sample

   git remote add origin git@github.com:DanielAdeniji/MSSQLTableSpoolPartitionIndexUnaligned.git

Git – Review Remote repositories

Syntax:

  git remote -v show

Command:

   git remote -v show

Output:

git remote -v show
origin	git@github.com:DanielAdeniji/HadoopHBaseDemoMedia (fetch)
origin	git@github.com:DanielAdeniji/HadoopHBaseDemoMedia (push)

 

Git - Remote - Show 

 

Git – Post changes from machine to Remote repository (1st Attempt)

The “git push origin master” replicates the local repository to a remote repository.
Syntax:

  git push origin master

Command:

   git push origin master

Output:


To git@github.com:DanielAdeniji/MSSQLTableSpoolPartitionIndexUnaligned.git
 ! [rejected]        
master > master (non-fast-forward)
error: failed to push some refs to 'git@github.com:DanielAdeniji/MSSQLTableSpoolPartitionIndexUnaligned.git'
hint: Updates were rejected because the tip of your current branch is 
behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

git - push origin master {2013-04-27 10_36 PM}

Git – Pull latest code from Remote repository to local directory

The error message above:
Updates were rejected because the tip of your current branch is behind its remote counterpart. Merge the remote changes (e.g. ‘git pull’) before pushing again.
suggests that we need to pull the latest version from github’s repository.

To do so, we will issue a “git pull” command.

Syntax:

   git pull <specific-repository-url>;

Example:

  git pull git@github.com:DanielAdeniji/MSSQLTableSpoolPartitionIndexUnaligned.git

Here is the output:

Command:

Output:


From github.com:DanielAdeniji/MSSQLTableSpoolPartitionIndexUnaligned
* branch HEAD > FETCH_HEAD
Merge made by the 'recursive' strategy.
README.md | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 README.md

git - pull {2013-04-27 11-06 PM}

Git – Post changes from machine to Remote repository (works)

Syntax:

  git push origin master

Command:

   git push origin master

Output:

   git push origin master
   Counting objects: 13, done.
   Delta compression using up to 8 threads.
   Compressing objects: 100% (12/12), done.
   Writing objects: 100% (12/12), 53.89 KiB, done.
   Total 12 (delta 3), reused 0 (delta 0)
   To git@github.com:DanielAdeniji/MSSQLTableSpoolPartitionIndexUnaligned.git
   4489d9f..a727695  master > master

Screen Shot

git - push origin master {2013-04-27 11-20 PM}

References

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s