Git Repository Spring Cleaning Using “BFG Repo-Cleaner”

Background

I will be the first one to admit it, a lot of what I write about is for nothing sake; it is just to write.

As mum reminded me this last weekend, “you talk just for the sake of talking“.

To which I laughed, knowing she said it in the most endearing way.

 

This Time

This time it is different, I have an actual problem.

And, I have had since yesterday or day before.

Wanted to upload files to github, but “no luck“.

 

Error Message

I issued “git post”, but got this message posted below:

Image

Textual

Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (13/13), 39.75 MiB | 2.78 MiB/s, done.
Total 13 (delta 2), reused 1 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 6a5c5cc6fc04a6cf086623cfa9f44576
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File WideWorldImportersDW.sql is 1003.32 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/DanielAdeniji/wideWorldImportersV2014.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/DanielAdeniji/wideWorldImportersV2014.git'

Explanation

  1. The key error message reads “File WideWorldImportersDW.sql is 1003.32 MB; this exceeds GitHub’s file size limit of 100.00 MB

 

Remediation

Git Commands

Remove File ( ** Does not work ** )

Remove File ( Syntax )


git rm --cached --ignore-unmatch [filename]

Remove File ( Sample )


git rm --cached --ignore-unmatch WideWorldImportersDW.sql

Result

  1. Commands
    • Committed Changes ( git commit )
    • Pushed ( git push )
  2. Same result ( not able to push changes)

 

Create & Add files to .gitignore ( ** Does not work ** )

Steps

  1. Using text editor, create a new file and name it .gitignore
  2. Add files to skip to .gitignore

.gitignore

Here is what the contents of the .gitignore file looks like:

Result

  1. Commands
    • Committed Changes ( git commit )
    • Pushed ( git push )
  2. Same result ( not able to push changes)

 

Rewrite History ( ** Does not work ** )

Syntax

Sample


git rm --cached --ignore-unmatch [filename]

git commit --amend -CHEAD

git push

Sample


rem https://stackoverflow.com/questions/21168846/cant-remove-file-from-git-commit
rem git rm --WideWorldImportersDW.sql

git rm --cached --ignore-unmatch WideWorldImportersDW.sql

git commit --amend -CHEAD

git push

BFG

Download

Please download bfg from here.

 

BFG – Prune specific file ( ** Does not work ** )

Script


Rem Find java.exe
rem set "_folder=C:\Program Files (x86)\Java\jre7\bin"
set "_folder=C:\Windows\SysWOW64"

rem set folder of jar files
set "_jarFolder=%CD%"

rem current file name of bfg file
set "_bfg=bfg-1.12.15.jar"

rem set name of file to remove
set "_file=WideWorldImportersDW.sql"

rem invoke bfg and pass along file to prune off
%_folder%\java -jar "%_jarFolder%\%_bfg%"  --delete-files id_{%_file%}

Output

Output – Image

Output – Textual

>rem set "_folder=C:\Program Files (x86)\Java\jre7\bin"

>set "_folder=C:\Windows\SysWOW64"

>set "_jarFolder=C:\Personal\dadeniji\Blog\Microsoft\SQLServer\SampleDB\v2016\WideWorldImportersDW\provisioning\v2014\v2014.20170823\SSMS\GenerateAndPublishScr
pts\script"

>set "_bfg=bfg-1.12.15.jar"

>set "_file=WideWorldImportersDW.sql"

>C:\Windows\SysWOW64\java -jar "C:\Personal\dadeniji\Blog\Microsoft\SQLServer\SampleDB\v2016\WideWorldImportersDW\provisioning\v2014\v2014.20170823\SSMS\Genera
eAndPublishScripts\script\bfg-1.12.15.jar"  --delete-files id_{WideWorldImportersDW.sql}

Using repo : C:\Personal\dadeniji\Blog\Microsoft\SQLServer\SampleDB\v2016\WideWorldImportersDW\provisioning\v2014\v2014.20170823\SSMS\GenerateAndPublishScripts
script\.git

Found 8 objects to protect
Found 3 commit-pointing refs : HEAD, refs/heads/master, refs/remotes/origin/master

Protected commits
-----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit 77ddf1c0 (protected by 'HEAD')

Cleaning
--------

Found 4 commits
Cleaning commits:       100% (4/4)
Cleaning commits completed in 46 ms.

BFG aborting: No refs to update - no dirty commits found??

Explanation

  1. BFG aborting: No refs to update – no dirty commits found??
    • Local Commits occurred
    • Commits to Remote Repository has yet to occur
    • And, thus not cited

 

BFG – Prune files bigger than [N] MB ( ** Works ** )

Script


rem set "_folder=C:\Program Files (x86)\Java\jre7\bin"

set "_folder=C:\Windows\SysWOW64"
set "_jarFolder=%CD%"
set "_bfg=bfg-1.12.15.jar"

rem ------------------------------------------------------------
rem $ java -jar bfg.jar --strip-blobs-bigger-than 100M
rem ------------------------------------------------------------
%_folder%\java -jar "%_jarFolder%\%_bfg%" --strip-blobs-bigger-than 50M

Output

Output – Image

Output – Textual


>invokeBFGBigFiles

>rem $ java -jar bfg.jar --strip-blobs-bigger-than 100M

>rem set "_folder=C:\Program Files (x86)\Java\jre7\bin"

>set "_folder=C:\Windows\SysWOW64"

>set "_jarFolder=C:\Personal\dadeniji\Blog\Microsoft\SQLServer\SampleDB\v2016\WideWorldImportersDW\provisioning\v2014\v2014.20170823\SSMS\GenerateAndPublishScri
pts\script"

>set "_bfg=bfg-1.12.15.jar"

>C:\Windows\SysWOW64\java -jar "C:\Personal\dadeniji\Blog\Microsoft\SQLServer\SampleDB\v2016\WideWorldImportersDW\provisioning\v2014\v2014.20170823\SSMS\Generat
eAndPublishScripts\script\bfg-1.12.15.jar" --strip-blobs-bigger-than 50M

Using repo : C:\Personal\dadeniji\Blog\Microsoft\SQLServer\SampleDB\v2016\WideWorldImportersDW\provisioning\v2014\v2014.20170823\SSMS\GenerateAndPublishScripts\
script\.git

Scanning packfile for large blobs: 1
Scanning packfile for large blobs completed in 14 ms.
Found 1 blob ids for large blobs - biggest=1052056478 smallest=1052056478
Total size (unpacked)=1052056478
Found 8 objects to protect
Found 3 commit-pointing refs : HEAD, refs/heads/master, refs/remotes/origin/master

Protected commits
-----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit 77ddf1c0 (protected by 'HEAD')

Cleaning
--------

Found 4 commits
Cleaning commits:       100% (4/4)
Cleaning commits completed in 343 ms.

Updating 1 Ref
--------------

        Ref                 Before     After
        ---------------------------------------
        refs/heads/master | 77ddf1c0 | 333b7745

Updating references:    100% (1/1)
...Ref update completed in 23 ms.

Commit Tree-Dirt History
------------------------

        Earliest      Latest
        |                  |
          .    D    m    m

        D = dirty commits (file tree fixed)
        m = modified commits (commit message or parents changed)
        . = clean commits (no changes to file tree)

                                Before     After
        -------------------------------------------
        First modified commit | c0bd8d32 | be390435
        Last dirty commit     | c0bd8d32 | be390435

Deleted files
-------------

        Filename                   Git id
        -----------------------------------------------
        WideWorldImportersDW.sql | 20342ad4 (1003.3 MB)

In total, 4 object ids were changed. Full details are logged here:

        C:\Personal\dadeniji\Blog\Microsoft\SQLServer\SampleDB\v2016\WideWorldImportersDW\provisioning\v2014\v2014.20170823\SSMS\GenerateAndPublishScripts\scrip
t.bfg-report\2017-08-25\14-00-00

BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive

--
You can rewrite history in Git - don't let Trump do it for real!
Trump's administration has lied consistently, to make people give up on ever
being told the truth. Don't give up: https://www.rescue.org/topic/refugees-america

Explanation

  1. Scan & Found
    • Scanning packfile for large blobs: 1
    • Scanning packfile for large blobs completed in 14 ms.
    • Found 1 blob ids for large blobs – biggest=1052056478 smallest=1052056478
  2. Deleted files
    • WideWorldImportersDW.sql | 20342ad4 (1003.3 MB)
  3. Next to do
    • BFG run is complete! When ready, run:
      • git reflog expire –expire=now –all && git gc –prune=now –aggressive

MVP!

Having others lean back, Like Eli Manning, the day belongs to Roberto Tyley!

His tool, BFG Repo-Cleaner,  sits on top of the castle.

It is Java and Scala and so works plentifully on all platforms!

Here is the link

 

References

  1. atlassian
    • Rewriting history
      • Git-Rewriting History
        Link

 

WordPress – Code Sharing – Github/Gist

Background

It is “Clean out the room” weekend.  And, I am here ruminating through all the dead wood, printed paper, clutter I have stored in my little bedroom.

The one I am currently on is the one by Chris Coyier and it is titled “Posting Code Blocks on a WordPress Site | CSS Tricks”.

Truth be told is was the inspiration behind our last post, as well.

 

Posting Code Blocks on a WordPress Site | CSS-Tricks

Chris post is available here.

Comment

A post is one thing, but taking the time to read the comment block is where one usually get all the fireworks.

What works, and what doesn’t.

Essentially, why the whole world is going to hell and why all this doesn’t really matter.

Hidden there somewhere, the reassuring “… but then you can try this, as well.”

 

Lewis Coyles

Here is the comment left by Lewis Cowles :-

Code

And, so the drill is you go to https://gist.github.com/.

Home Page

 

Data Entry

You do a bit of data entry

  1. Gist Description
    • Give the code a bit of description
  2. File name
    • Filename and extension
  3. Code Block
    • Enter the code snippet
  4. Private or Public
    • Indicate whether private or public
    • Public
      • Search Engines will collect metadata
    • Private
      • Excluded by Search Engines
    • Anyone with URL can access it

 

WordPress

Come back to wordpress.

Post Editor

The easiest for me to is to just access the Text tab and use the gist tag.

Sample Code

Sample Output

Original Code

Revised Code

 

More

Please read more here….

Git – GitHub – Private Repositories

Background

A bit over 4 years ago, I read Troy Hunt’s blog titled “The Ghost Who Codes: How Anonymity is Killing Your Programming Career“.

 

Troy Hunt – The Ghost Who Codes: How Anonymity is Killing Your Programming Career

It is available here.

And, here are all the places he looked for the anonymous programmer….

.

 

4 Years Later

It is 4 years later, enough time to go through college, and get a college degree.

In between signed up for free GitHub.

Private Repositories

It is now time to sign up for a paid version.

Why Private

The reasons are numerous and includes:

  1. Need for secured storage
    • Sometimes I have code that is not yet complete, but I will still like to save to a location other than my laptop
    • Occasionally have proprietary data such as credentials or server names that I will rather not share with the whole world
  2. Saving Things Online
    • Forces better coding practice
    • Structure
    • Succinct

 

Steps

To create private repositories, you need to pay monthly or yearly fees

Outline

  1. Sojourn to github
  2. Login to your Account or create a new one
  3. On the top new bar click on the + sign
  4. In the “New Repository” window
    • Enter the Repository Name
    • In the “Public or Private” Group box, Choose Private
    • Enter Credit Card Info

 

Screen Shots

Menu – New Repository

On the top menu bar, click on to + sign

Repository – Private

Choose to create a Private Repository…

 

Soul Searching

It is incredible how little it takes to encourage better Angels

  1. Linux Torvalds
    • Lord of the Files: How GitHub Tamed Free Software (And More)
      Link
  2. Troy Hunt
    • Troy Hunt web site
      Link

 

Dedicated

Dedicated to Troy Hunt

Image

 

Textual


02 June 2017

I’m in Belgium! After 35 hours of travel to Porto in Portugal then 2 days of workshop plus a user group there, I’m now in Leuven which is in the home of epic Belgium beer. I’m now into day 2 of another workshop here after having done a user group on Azure last night so it’s turning into a very long week. Not a lot of new stuff to talk about blog wise, but I share what it’s like doing these events and some of the things I learn along the way.

Git – Error – “git push” failing with error “Updates were rejected because the tip of your current branch is behind”

Background

Trying to update files in one of our public github repositories, but failing with the error message pasted below.

 

Command

Here is the simple command I ran:

git push

That command obviously succeeded git add and git commit.

 

Error

Image

tipofcurrentbranchisbehind-20170126-1014am

 

Textual

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

Explanation

  1. Key Terms
    • error: failed to push some refs to
    • hint: Updates were rejected because the tip of your current branch is behind

 

Remediation

“Git Reset”

Source

Stack Overflow

What’s the best practice to “git clone” into an existing folder?
Link

stack-overflow-user1055643

 

Code



rem set gitURL
set _gitURL=https://github.com/DanielAdeniji/sp_ListObjectLevelPermissions.git

rem remove git folder
rmdir /S /Q .git 

rem git init
git init

rem git remote add origin to Git URL
git remote add origin %_gitURL%

rem git fetch
git fetch

rem git reset
git reset --mixed origin/master

Explanation

  1. Please replace the variable _gitURL with the your Git Repository

Output

gitreset-20170126-1057am

 

Summary

As always, nothing but the Internet saves.

Technical: Installing and Using GIT Command Line Interface on CentOS

Technical: Installing and Using GIT Command Line Interface on CentOS

Background

Now that my primary box is this CentOS Linux box, I need to make sure that I can share a bit on it.

With a web browser, I am able to post to wordpress.

And, I probably can look for a web interface to get to github, as well.  But, I really need to re-familiarize with Bash and command line stuff.

And, so I will stay away from nice, pretty GUI for now.  And, go shell.

 

Installation

On CentOS, we can install via the yum.

sudo yum install git-core

Yum install is easy as it takes care of installing all the dependant files.

 

Customize

 

Set User name

git config --global user.name "Daniel Adeniji"

Set email address


git config --global user.email "Daniel_Adeniji@nobody.com"

 

 

Create a repository

Connect to your github online account, and create a new repository

 

Identify local folder on host

On your Linux\Cent OS host, identify or create local folder that will serve as your working folder.

In our case, we will use /home/dadeniji/development/apache.org/tomcat/MSAdventureWorksDWDB.Public

 

Change Working Directory

Make identified folder your working directory

Launch Unix terminal and change working folder to identified folder.

Syntax:

cd <working-folder>

 

Sample

cd /home/dadeniji/development/apache.org/tomcat/MSAdventureWorksDWDB.Public

 

Clone Git Repository

Clone Git Repository

Syntax:

git clone git@github.com:<user-name>/<file>.git

 

Sample:


git clone git@github.com:DanielAdeniji/JavaJSPJSTLMSSQL.git

 

Output:

Here is the output we got back…




[dadeniji@adelia MSAdventureWorksDWDB.Public]$ ssh -vT git@github.com
OpenSSH_6.6, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.252.130] port 22.
debug1: Connection established.
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/dadeniji/.ssh/known_hosts:2

debug1: No more authentication methods to try.
Permission denied (publickey).
[dadeniji@adelia MSAdventureWorksDWDB.Public]$ 


 

 

Set up SSH Keys

We know that we have yet to set up SSH keys on this box.  And, unfortunately I do not recollect where I placed previously used ones.

So let us go re-create SSH (Private & Public) keys.

Thankfully, GitHub has very good documentation on doing so:
https://help.github.com/articles/generating-ssh-keys

SSH Key Folder Location

SSH Keys are kept in /home/<username>/.ssh and in our case it is /home/dadeniji/.ssh.

In Linux by convention folders whose name starts with . are hidden files.  And, so the folder might not show up.

Here is a default listing Folder Listing:

Folder-List-Visually

 

Enhanced Folder Listing:

On CentOS, to view hidden files, please click on the menu items “View”/ “Show Hidden Views” or use the keystrokes (CTRL-H).

Here is the “Show Hidden Views” picture:

Folder-List-Visually-after

 

 

Check for SSH Key

Command:


cd ~/.ssh
ls -al

Output:

 

ssh - list files

Generate SSH Key

Command:

ssh-keygen -t rsa -C "dadeniji@ephraimtech.com"

 

Output:

ssh-keygen

 

Add Key to SSH Agent

Command:

ssh-add ~/.ssh/id_rsa

 

Output:

ssh-add

 

Review SSH Keys

Let us re-issue ls, and see whether we now have our keys.

Command:

cd ~/.ssh
ls -al

Output:

ssh - list files (found)

Add SSH Keys to Git-Hub

  • Access Github
  • In the top bar (https://github.com)
  • topMenuClick on the wrench button    wrench  .
  • The “Account Settings” ( https://github.com/settings/profile ) will show up
  • The “Account Settings” screen looks like this:AccountSettings
  • Click on “SSH Keys”
  • SSH Keys:Listing for SSH Keys.SSHKeys
  • Click on the “Add SSH key”AddSSHKey
  • Post entering SSH KeyAddSSHKey [after]
  • Confirm password to continue — Enter passwordConfirmPasswordToContinue
  • Here is the the listing of our “SSH Keys”SSHKeys (After)
    We can see that the new key’s status is listed as  “Added just now — Never used“.

SSH Key – Test

Command:

ssh -T git@github.com

 

Output:

Output – Textual:


[dadeniji@adelia ~]$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
Hi DanielAdeniji! You've successfully authenticated, but GitHub does not provide shell access.
[dadeniji@adelia ~]$


Output – Image:

PermanentlyAddedTheRSAHostKeyForIPAddress

 

 

Clone Git Repository (Attempt #2)

Clone Git Repository

Syntax:

cd <home-directory>

git clone git@github.com:<user-name>/<file>.git

 

Sample:


cd /home/dadeniji/development/apache.org/tomcat/MSAdventureWorksDWDB.Public git clone git@github.com:DanielAdeniji/JavaJSPJSTLMSSQL.git

 

Output:

Here is the output we got back…

Textual:


Initialized empty Git repository in /home/dadeniji/development/apache.org/tomcat/MSAdventureWorksDWDB.Public/JavaJSPJSTLMSSQL/.git/
warning: You appear to have cloned an empty repository.


 

Image:

cloned-empty-git-repository

 

Git Repository – Add

Add Files

Syntax:

cd <home-directory>

git add <files>

 

Sample:


git add '*.jsp'

 

Output:

Textual:

fatal: Not a git repository (or any of the parent directories): .git

 

Image:

NotAGitRepository

 

Remediate

Googling on the error message tells me that I really needed to have indicated the folder that I wanted to use as my Git current folder.

As we did not indicate otherwise, a new folder is created underneath the current folder bearing:

inproper-use-of-git-clone

 

In the screen above the name of the folder is JavaJSPJSTLMSSQL.

 

Move Git Local Repository

Move Git Local Repository

Syntax:

cd <home-directory>

mv <local-folder>/.git . 

rm -rf <local-folder>

 

Sample:


cd /home/dadeniji/development/apache.org/tomcat/MSAdventureWorksDWDB.Public move JavaJSPJSTLMSSQL/.git . rm -rf JavaJSPJSTLMSSQL

 

Check Git Local Repository

 

Syntax:

git status --short

 

Sample:


git status --short

 

Output:

gitStatus--short

 

Reset Git Local Repository – Reset

 

Syntax:

git reset --hard

 

Sample:


git reset --hard

 

Output:

Textual:


fatal: Failed to resolve 'HEAD' as a valid ref.

 

Image:

failed to resolve head

 

We will ignore this error for now.

Git Repository – Add

Add Files

Syntax:

cd <home-directory>

git add <files>

 

Sample:


git add 'README.md'
git add '*.jsp'
git add '*.html'
git add 'META-INF/context.xml'
git add 'WEB-INF/*'

Git Repository – Create ignore file (.gitignore)

Add Files

Syntax:

touch .gitignore

 

Sample:

 

touch .gitignore

 

If there are files that we do not want shipped-off, we will list them in the .gitignore file.

Mask Private Data

We will like to share source code, but keep certain private data hidden.  We will use sed for that.

 

Sample:


sed --expression='s/HRPROD/dbHost/' --expression='s/username="hrdb"/username="dbUser"/' --expression='s/mygoodpwd/dbUserPassword/' META-INF/context.xml > META-INF/context.xml.tmp && mv META-INF/context.xml.tmp META-INF/context.xml sed --expression='s/HRPROD/dbHost/' --expression='s/hrdb;/dbUser;/' --expression='s/mygoodpwd/dbUserPassword/' jspSimple.jsp > jspSimple.jsp.tmp && mv jspSimple.jsp.tmp jspSimple.jsp

 

 

 

Git – Review File Status

Review Git Status in terms of what files are on.

Syntax:

git status

 

Sample:

git status

 

Output:

gitStatus

 

 

Git – Commit Changes – Locally

Commit Git Changes locally.

Syntax:

git commit -m <comment>

 

Sample:

git commit -a -m "initial batch"

 

Output:

gitCommit

 

Git – Commit Changes – Remotely

Commit Git Changes remotely.

Syntax:

git push -u origin master

Sample:

git push -u origin master

 

Output:

gitPush

 

Git – Review Github

Let us quickly review Github and make sure that our files are there.

Our URL is https://github.com/DanielAdeniji/JavaJSPJSTLMSSQL.

 

exploreFilesOnGithub

 

 

 

Git – Review Log

We use “git log” to review our change logs.

Syntax:

git log

Sample:

git log

Output:

gitLog

 

Listening to

Dave Loggins – Pieces of April
https://www.youtube.com/watch?v=gAlaYEmS0oY

 

 

References

References – Git – Tutorial

 

References – Git – SSH Key Management

 

References – Git – Q/A

 

References – Git – SSH Key – QA

 

 

References – SSH Key – Management

  • Git Tutorial starting with git using 10 commands

 

 

 

 

 

 

 

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

GitHub Client Installation on Mac OSX

Introduction

Two months ago, to be exact on Feb 13th, 2013, I read Troy Hunt’s posting titled “The Ghost Who Codes: How Anonymity is Killing Your Programming Career” (http://java.dzone.com/articles/ghost-who-codes-how-anonymity).

Ever since I have being meaning to get a GitHub Account.  Today I finally did.

As I am cheap and I am mostly doing so as part of Mr. Hunt’s assigned home work, I went the path of a free, publicly available repository.  No Credit Cards, Nothing!

Here is a quick primer on how to install a GitHub Client on a Mac OS.

Tools – Command Line

The official tools are available @ http://git-scm.com/downloads.

The URL for the Mac OSX version is available @ http://git-scm.com/download/mac

Tools – GUI

A very good brochure of GitHub clients is available via http://git-scm.com/downloads/guis 

Tools URL Price
GitHub for MAC http://mac.github.com/ Free for personal Usage
Gitbox http://gitboxapp.com/ Free for personal Usage
GitX http://gitx.laullon.com/ Free for personal Usage
Atlassian – SourceTree http://www.sourcetreeapp.com/ Free for personal Usage
Collab.Net – GitEye http://www.collab.net/giteyeapp Free for personal Usage
Syntevo – SmartGit/Hg http://www.syntevo.com/smartgithg/index.html Free for personal Usage

Tools – Command Line – Install

  • Download the installer for your OS
  • In our case, our installer is http://git-scm.com/download/mac
  • Once the installer is downloaded, launch it
  • The first screen that will appear is the screen  pasted below and labelled “Git 1.8.2.1 Snow Leopard Universal”
  • On the screen labelled “Git 1.8.2.1 Snow Leopard Universal”, double-click on the “Git-1.8.2.1-Intel-universal-snow-leopard.pkg” icon
  • The first screen displayed is the Git Welcome Screen
  • The next screen is the “Standard Install on …”
  • The next screen is the “Install Confimation” Screen

Git – Installer – Extracted (1.8.2) – Installer

Git 1.8.2.1 -- Snow Leopard Intel Universal

Git Welcome Screen

GitHub - Welcome Screen

Confirm Install

Git - Install Confirm

Installation was successful

Git - Installation was succcessful

Tools – Command Line – Uninstall

The script for the Un-installer is pasted below.  The name of the file is uninstall.sh.

Here is what the uninstaller does:

  • Checks the default install folder (/usr/local/git)
  • If that folder is not present, the script terminates and returns 1
  • The user is prompted as to whether he/she wants to continue
  • Upon pressing yes, the following folders are removed /usr/local/git//etc/paths.d/git, and /etc/manpaths.d/git
  • The pkgutil utility is invoked

if [ ! -r "/usr/local/git" ]; then
  echo "Git doesn't appear to be installed via this installer.  Aborting"
  exit 1
fi
echo "This will uninstall git by removing /usr/local/git/**/*, /etc/paths.d/git, /etc/manpaths.d/git"
printf "Type 'yes' if you sure you wish to continue: "
read response
if [ "$response" == "yes" ]; then
  sudo rm -rf /usr/local/git/
  sudo rm /etc/paths.d/git
  sudo rm /etc/manpaths.d/git
  sudo pkgutil --forget --pkgs=GitOSX\.Installer\.git[A-Za-z0-9]*\.[a-z]*.pkg
  echo "Uninstalled"
else
  echo "Aborted"
  exit 1
fi

exit 0

Uninstaller steps are:

  • Right click on the downloaded file (git-xxx-intel-universal-snow-leopard.dmg)
  • From the drop-down menu, select DiskImageMounter
  • The screen shot below is shown
  • You want the uninstall.sh file; place that file somewhere you can get to  it (/tmp folder)
  • Launch Terminal
  • Issue “cd /tmp”


Git – Installer – Extracted (1.8.2) – Uninstaller

Git - Installer - Extracted (1.8.2)

Review Install

Post install, review install

Once the installation has complete, please take the following steps to review:

    • Launch a new terminal window (this ensures that your environment variable such as path have been updated)
    • Issue “git -version”

git --version

Git - Command -version

Book

Scott Chacon has a free book online.  The URL is http://git-scm.com/book.

References

References – pkgutil