• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Create a VM ($25 Credit)
  • Buy a Domain
  • 1 Month free Back Blaze Backup
  • Other Deals
    • Domain Email
    • Nixstats Server Monitoring
    • ewww.io Auto WordPress Image Resizing and Acceleration
  • About
  • Links

IoT, Code, Security, Server Stuff etc

Views are my own and not my employer's.

Personal Development Blog...

Coding for fun since 1996, Learn by doing and sharing.

Buy a domain name, then create your own server (get $25 free credit)

View all of my posts.

  • Cloud
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • How to buy a new domain and SSL cert from NameCheap, a Server from Digital Ocean and configure it.
    • Setting up a Vultr VM and configuring it
    • All Cloud Articles
  • Dev
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • How to setup pooled MySQL connections in Node JS that don’t disconnect
    • NodeJS code to handle App logins via API (using MySQL connection pools (1000 connections) and query parameters)
    • Infographic: So you have an idea for an app
    • All Development Articles
  • MySQL
    • Using the free Adminer GUI for MySQL on your website
    • All MySQL Articles
  • Perf
    • PHP 7 code to send object oriented sanitised input data via bound parameters to a MYSQL database
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • Measuring VM performance (CPU, Disk, Latency, Concurrent Users etc) on Ubuntu and comparing Vultr, Digital Ocean and UpCloud – Part 1 of 4
    • Speeding up WordPress with the ewww.io ExactDN CDN and Image Compression Plugin
    • Setting up a website to use Cloudflare on a VM hosted on Vultr and Namecheap
    • All Performance Articles
  • Sec
    • Using the Qualys FreeScan Scanner to test your website for online vulnerabilities
    • Using OWASP ZAP GUI to scan your Applications for security issues
    • Setting up the Debian Kali Linux distro to perform penetration testing of your systems
    • Enabling TLS 1.3 SSL on a NGINX Website (Ubuntu 16.04 server) that is using Cloudflare
    • PHP implementation to check a password exposure level with Troy Hunt’s pwnedpasswords API
    • Setting strong SSL cryptographic protocols and ciphers on Ubuntu and NGINX
    • Securing Google G Suite email by setting up SPF, DKIM and DMARC with Cloudflare
    • All Security Articles
  • Server
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • All Server Articles
  • Ubuntu
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • Useful Linux Terminal Commands
    • All Ubuntu Articles
  • VM
    • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
    • All VM Articles
  • WordPress
    • Speeding up WordPress with the ewww.io ExactDN CDN and Image Compression Plugin
    • Installing and managing WordPress with WP-CLI from the command line on Ubuntu
    • How to backup WordPress on a host that has CPanel
    • Moving WordPress to a new self managed server away from CPanel
    • Moving a CPanel domain with email to a self managed VPS and Gmail
    • All WordPress Articles
  • All

git

How to create a Private GitHub repository and access via SSH with TortiseGIT

July 17, 2021 by Simon

Here is a guide on using the GUI TortoiseGIT, GIT for Windows with GitHub.

Creating a GitHub Account

Make sure you have a GitHub account (free is OK)  https://github.com/

GitHub Main Page

Login to GitHub

Github login page

I used my defined hardware Security Key

I used my defined security key

I clicked New Repo

New Repo button

Repo Settings

  • I set Private
  • Added a readme
  • Set .gitignore for Visual Studio files
  • I had no idea what licence to select (read more on licences here)
repo settings as desired

I clicked Create repository

The repo is now ready for files

Creating RSA Keys

Now I will create an SSH key to protect communications with GitHub.

When logged into GitHub, I clicked the SSH and GPG Keys menu

I clicked New SSH Key button

New SSH Key Button

GitHub wants a public SSH Key

Add SSH Key Here

More on Generating SSH Keys

I used this command to generate a public and private SSH key

ssh-keygen -t rsa

Generate key output.

FYI: These Keys have been deleted, they have not been used beyond this demo

A Public and Private key was generated

Public and Private Key in explorer

id_github_test.pub = Public Key

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDKeAydCIpEB9EuBH/h0FbsnhUlmQT/ylKowlOWEkvl0CRZO2b7ak71GI5V4IJtVESjx/yZ3hHAhlOYp5VXbpTXv9rbKGEA12ii6d7cNOzfaAq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fUMRMI4VaARH2Y1pX4
MtLfAjPPFkYF2GFnI1eUnexH36FS6DKoM5/YhQbqMlsEtzsyH2l2sosd/PgITpq94quToA
Cr12uXaYy/037pNutZXPkYD5R5vwcZgnAu8d3KOA+VzRedz1R4K4iTGgfoRRFyjz1tugvM
ruJGLDyAk09JDoqWasFtpsjjGAt9Z9s34s9PbQggFFs44ZbBvPeaD5peBbaP6bo1ekG+2B
5A+zMkeajCoKJx/W3T7oZeSL5Z9SscwsmcPRA/hP9tfXMKA93b55pHgXlu0Qbkvm3mrd05
a3RrrPCfy8dJAeW7ieR1p+BSc7t1btZfQ1n2HF994hOEkkWZ1lghXNY0/F5eP6glDnT795
ZPx00M96+6Jz7EnJOblQemfKfB3Da33MgyTMnQ/5kzQMMhk2KD7CFvzFXuVmA0oTy8Ney6
6w7BreBWYmuNUYPa+WGxkkGlivMf0a4uIcjNcPD/eyKnAp+sbRP8ZrfKFyAaZC8KWNkhPf
GA13aqMF2vIDCBTlvhMN8uGsojn7f4NVy8Frvqbm+ZqG3TwSrtgUfx2cXN1QLXvuAcFc0z
BQrh4aLy31dXpzoj0cPp3DMQF7jyp6mhcFopICrpUW+2wQKD8wOMc1BtziIpJtDXFQrh3l
QhN3/T15hnwgrt2qO/cyP0MxNLgVqN8F1+Am2gPqASyI0U/mZbh1W0ydpupcHBRc/BN37U
pc6KwT2uQ8D/b/Y8etn3QSlcTnVzZIFSSUWTHJKDnGIh/UwFj/6rESuuV+oSmH3nTVAjPT
XDTZUjd3GH7R4Ghf5dfl7eouHHLvYd58EVSZV1kGEY7W3jk74y0Vkjx9unjY1TtolIiNkD
A6h6Yt32e8MjNec0XzVHjEbXn+8=
-----END OPENSSH PRIVATE KEY-----

FYI: These Keys have been deleted, they have not been used beyond this demo

I added the Public Key to GitHub

Pased Public SSH Key

SSH Keys are listed in GitHub

Multiple SSH Keys

I create a different key per repository.

Setup Git Locally

I checked to see if the “git” command was installed on my local machine.

No Git

I will install Git from https://gitforwindows.org/ 

Git for Windows Webpage

I download Git-2.32.0.2-64-bit.exe and started the installer

Installing GIF WIzard

Folder C:\Program Files\Git

Choose a folder

Set Options (e.g I like Check for Daily updates)

GIt Options

Start Menu Folder

Start Menu

Text Editor: I like Sublime Text from https://www.sublimetext.com/3

Set Test Editor

Set an Initial Branch name

Initial Branch Name

Set 3rd party software options

3rd party options

Set HTTPS options

Open SSL

Set Line Endings preferences

Line Ending Preferences

Set Terminal Emulators preferences

Terminal Emulator settings

Set Git Pull default preferences

git pull defaults

Set Credential Manager preferences

git credential preferences

Set Extra Options

Set Options

Experimental Options

Opt out of experimental options

Installing

Installing

First Launch

First launch

Git is installed

Install Tortoise GIt

Visit https://tortoisegit.org/

Tortoiuse git website

Download Gif (64bit)

Download options

I started the installer.

Setup Wizard.

Licence Agreement

Licence Agreement

SSH Type

set ssh type

Components

Componentts

Install

Installing (Wizard)

Install


Language: English

 

English

Shell Extension

Shell Integration

I checked for a known git path.

Git path check

I set my desired git username and email

Default git username

I set desired SSH settings

SSH Settings

Folder for Code Repositories

I create C:\Code\MyTestRepo

C:\Code

Before I can clone a repository I need o set the past to SSH in TortoiseGit.

I right-clicked on C:\Code\MyTestRepo and selected TortiseGit\Settings

TortoiseGit Settings

I expanded the Network Node and set the following as the SSH Client

“C:\Program Files\TortoiseGit\bin\TortoiseGitPLink.exe”

SSH Client Set

I saved the Settings.

Clone a GitHub Repository via git and Tortoise GIT

Now I can clone a repositor to C:\Code\MyTestRepo, 

I right clicked on C:\Code\MyTestRepo in explorer and clicked Git Clone

I added by GIT URL (Obtained from GitHub), I also set the path for the Private Key I created earlier.

Git Clone

I was informed that the key is in the wrong format

Wrong Format Error

I need to convert the RAS Private Key to a Putty PPK Key

Convert an RSA Key to a Putty PPK with PuuttyGen

I opened the Open Putty Gen

https://www.puttygen.com/

I click Load and select the id_github_test private key I created earlier

Load private key

I entered my private key password

Private Key Password.

The private key loaded.

Private Key Loaded

Now I can export the private key to a PPK format

Export as PPK

Clone (with a PPK Private Key)

Getting back to cloning a repository I right-clicked on C:\Code\MyTestRepo

I set the PPK private key

Clone with PPK

I entered the password

Enter password

I accepted the key

Accpet key

The Repository started cloning.

Repository Cloning

Creating a Quick Visual Studio Project

I created a quick Visual Studio project and saved it to C:\Code\MyTestRepo\Hello World

New Visual Studio project

Visual Studio files were visible in C:\Code\MyTestRepo

C:\Code\MyTestRepo

I Commit the new files to the repository (main branch)

Commit

I selected desired files to commit

Commit

Files were added

I right-clicked on C:\Code\MyTestRepo and selected TortoiseGit\Push

Push Dialog

Files are now visible in GitHub

Awesome

Setup on Multiple Machines

I set up Git on multiple machines, cloned, made chances, committed those changes and pushed.  I was able to Sync down those changes to each machine.

Good advice on Using Git

  • Git Guides – git push (github.com)
  • What is git commit, push, pull, log, aliases, fetch, config & clone | by Ameet Prajapati | MindOrks | Medium
  • GitHub 101 — Introduction to GitHub for Newbies | by Arerosuoghene Wisdom | Medium

Happy Coding

Filed Under: Code, Git, GitHub, Uncategorized, Windows Tagged With: git, GitHub, gui, TortoiseGit, windows

Setting up BitBucket on an iMac and creating a project

June 30, 2017 by Simon

I use Jira for managing software development tasks on AWS and Digital Ocean and I recently tried out GitHub, It’s about time I checked out the free BitBuucket.

I have a dedicated Jira software page at https://mysecertprojectnamehere.atlassian.net/ and from there I can set up a BitBucket account. I read the use SSH with Bitbucket and setup SSH for git.

BitBucket

I downloaded the BitBucket v2.5.3 application for free. BitBucket offers free private repositories for up to 5 users, 1GB total and 50 build minutes with pipelines. Get started with pipelines guide.

BitBucket

I needed to log in to bitbucket.org before signing up. I have a few Atlassian accounts so I made sure I logged in with the right account.

After logging in I was prompted with the Bitbucket beta (I said OK).

BitBucket

BitBucket beta is now activated now I can create a repository.

BitBucket

It appears BitBucket gives you 1Gb file storage for free, then $10 after that for 100 GB.

The next thing I did was include a menu item (link) to my new BitBucket Account in my Jira (Settings then Applications then Application Navigator) in Jira.

Now I can easily get to my BitBucket from JIRA.

When you create a repository on BitBucket you can import a repository from GitHub (I imported my repo that I created in GitHub).

I was able to import my GitHub project I created in this blog post ok.

Adding SSH Keys Locally

You can find SSL related SSL settings by clicking your user profile picture when logged into https://bitbucket.org/ then Bitbucket settings.

Then click SSH Keys.

As with GitHub we can generate a local machine generated SSH key and assign it to BitBucket to prevent using BitBucket password when we push code to BitBucket.

You can learn how to generate a key here.

Locally I entered a terminal and typed the following to generate a key.

cd ~/.ssh
mkdir backup
sudo cp *.* backup/
ssh-keygen -t rsa -C "bitbucket [email protected]"

I entered the following output filename when generating the key.

bitbucket_rsa.pub

Performing a list directory in terminal you should see two new files.

cd ~/.ssh/
ls -al
total 80
drwx------  13 simon  staff   442 30 Jun 22:19 .
drwxr-xr-x@ 92 simon  staff  3128 28 Jun 00:56 ..
...
-rw-------   1 root   wheel  3326 27 Jun 22:45 githubrsa
-rw-r--r--   1 root   wheel   742 27 Jun 22:45 githubrsa.pub

You can use this command to copy the new public SSH key to clipboard.

cat bitbucket_rsa.pub | pbcopy

You can now paste this SSH key into Bitbucket’s UI.

I edited the description of the SSH key to include my laptop name.

You can see how I set up SSH keys on GitHub here.

You will also need to add your SSK key to the end of the known_hosts file

# edit the known_hosts file
sudo nano known_hosts
# Add this to the end of your known_host file (keep all contents in this file)
bitbucket.org,104.192.143.3,131.103.20.167,131.103.20.168,131.103.20.169,131.103.20.170 ssh-rsa AAAA_paste_your_ssh_key_text_here bitbucket [email protected]

I found the possible listening Atlassian Bitbucket serves here. Atlassian recommend you monitor the @bitbucket account on twitter and watch the bitbucket status page.

Verifying your SSH connection to Bitbucket

sudo ssh -T [email protected]
The authenticity of host 'bitbucket.org (104.192.143.2)' can't be established.
RSA key fingerprint is SHA256:removed.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,104.192.143.2' (RSA) to the list of known hosts.
Permission denied (publickey)..

I have issues with my terminal connecting to BitBucket?  I have asked @Bitbucket and have not had a response.

My following command was failing?

sudo ssh -T [email protected]
Permission denied (publickey).

I thought I would give the Bitbucket Gut SourceTree application a try.

BitBucket

I downloaded the zip file containing the application and ran the install wizard.

BitBucket

Unfortunately, the Atlassian Bitbucket SourceTree application failed to allow my account to sign in (infinite spinning wheel of death for 24 hours) – note the spinning wheel near the Cancel button.

BitBucket

I have had no luck getting SSH access to bitbucket from the terminal or SourceTree to log in. I asked @BitBucket for help on Twitter but have not heard anything.

In desperation, I tried again and this time selected HTTPS in SurceTree and was asked to grant access to my account (read and modify).

BitBucket

I can now see remote repositories (with my logged in identity).

BitBucket

Syncing (Pulling) the Repository with SourceTree

Time to check out an empty project #1 (repository clone) in SourceTree (seems SSH /terminal is not working in BitBucket).

BitBucket

This worked, I can see files locally.

BitBucket

Now it is time to clone a larger project that I imported from GitHub.  This one took a little longer to clone.

BitBucket

All files synced down ok and teh SourceTree application is looking good.

BitBucket

Adding my first new local file(s) to the repository

Bitbucket is not working via terminal/SSH yet so I added a file ( called “testbitbucketfile.txt”) in Finder and tried to upload it with SourceTree by selecting Workspaces then File status then checking the file to ensure it was going to be uploaded (I was expecting a prompt to add the file after I created it but nothing appeared).

BitBucket

Submitting (pushing) changes (adding another file)

Because BitBucket was not working via terminal/SSH I tried to commit via SourceTree.

I selected Push then OK.

It appears I have an authentication error when I sync (why?, I am logged in and can see repositories and I granted read/modify access earlier)?

> Error: “Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile. fatal: Authentication failed”.

My account has been pre-authenticated, what gives SourceTree?

The only option I can see is switching to “basic” authentication (no thanks).

More worryingly BitBucket Source Tree reports “Completed successfully” when it is clear that the new files were not uploaded.

I appear to have to write access permissions for my repo so I have no ideas what is wrong.

I may be wrong but it appears I need to be a paid user to have a working Git repository?  Time to use GitHib (as I know it works with SSH and syncs files).

This hereby ends my BitBucket test. I have no working BitBucket SSH environment on my OSX , poor support from Atlassian (poor documentation, slow social media replies and poor SourceTree error messages/UI) and SourceTree is overly optimistic on actions. I was logged in, granted read/modify access to SourceTree but I am unable to push back to a repo?

Atlassian support

I received a message on my question on Twitter to @bitbucket and was asked to log a support issue.


I googled Atlassian support


I logged in and tried to log a support request but got stuck in an update profile loop

When I clicked save I was not redirected anywhere new and was directed back to the update profile details screen (no other tabs were open on my mobile device Safari/iPhone).

I submitted a bug report on a desktop browser (bug 4825 on the BitBucket/SRCTREE for Mac Jira).

Conclusion

I’ll stick with using  GitHub (paid to get private repos) as Github’s SSH is working for me and files synced ok from the terminal with little effort. I am not happy with Bitbucket’s SSH (never got it working), SourceTree and Atlassian’s products appear to have many  (700+) undocumented features.

Agile Project Management

Read my blog post on developing software and staying on track here.

I highly recommend you follow Dmitri Iarandine at http://joinagile.com/ (Agile Coach, Trainer, Host of Lean and Mean Agile). Podcast. Author of GET HIRED as SCRUM MASTER).

Dmitri can be found here too.

Soundcloud (Lean and Mean Agile Podcast):
https://soundcloud.com/user-364782318

iTunes:
https://itunes.apple.com/au/podcast/lean-and-mean-agile-podcast/id1269551866

YouTube:
https://www.youtube.com/channel/UC00OZqfM9VmznEOTVzrQQxw

Twitter:
http://twitter.com/iarandine

Udemy:
https://www.udemy.com/agile-coaching-101/

Amazon:
https://www.amazon.com/author/iarandine

Tips and Troubleshooting

BitBucket tutorials.

Git tutorials.

You may need to set up a new branch for each repository and assign permissions before you can read the repositories.

Donate and make this blog better




Ask a question or recommend an article
[contact-form-7 id=”30″ title=”Ask a Question”]

v0.94 added info on agile and staying on track

Filed Under: Atlassian, BitBucket, Git, IoT Tagged With: bitbucket, git, sourcetree

Setting up GitHub on an iMac and creating a project

June 25, 2017 by Simon

Here is my quick guide on setting up a new GitHub repository on an iMac adding files and syncing with a  repository. Read the GitHub 101 if you are a beginner. Read my BitBucket guide here.

Why

Using git allows you to make backups, use code versioning, rollback code, use multiple development machines/have multiple users, auto merging code etc.

Github can be cheaper, more flexible and offer more features than something like Dropbox.

How

Create an account at GitHub and Login ( https://github.com/login ).

Don’t forget to set up Two Factor Authentication for extra security.

Login to GitHub (signup for a free account if need be).

Enter your Two Factor Authentication code every time you login.

Before you can read or write to your Git repository you need to set up a link between your computer (Mac) and GitHub by Setting up a Secure SSH Key with GitHub. About SSH.

If you have read any of my guides on setting up servers (e.g The quickest way to setup a scalable development IDE and web server, How to buy a new domain and SSL cert from NameCheap, a Server from Digital Ocean and configure it or Connecting to an AWS EC2 Ubuntu instance with Cloud 9 IDE as user ubuntu and root ) you will be familiar with SSH keys.

You can check your existing SSH Keys by typing the following.

ls -al ~/.ssh

Follow this GitHub guide on creating a new SSH key to use with GitHub.

I found I had to do the following in the Mac terminal to get this to work.

eval "$(ssh-agent -s)"
mkdir /gitrsatemp
cd /gitrsatemp
sudo ssh-keygen -t rsa -b 4096 -C "[email protected]"
# specify output as /gitrsatemp/githubrsa
# used a passphrase from https://www.grc.com/passwords.htm
mv /gitrsatemp/* ~/.ssh/
cd ~/.ssh/
ssh-add -K ./githubrsa

You can now add your SSH key to GitHub. 

cd ~/.ssh/ 
sudo pbcopy < ./githubrsa.pub

You can then add your public key to https://github.com/settings/keys

Add the SSH Key.

You can then test the SSH connection to GitHub.

At first, I tried this but got an error.

sudo ssh -T [email protected]
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:key_redacted.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.

This is what I got when I added my SSH Key to my GitHub account. This worked for me (this updated my known_hosts file).

sudo ssh -T [email protected]
Hi SimonFearby! You've successfully authenticated, but GitHub does not provide shell access.

Tip: Don’t forget to save adding your SSH Key to GitHub

If you need help contact GitHub.

GitHub Pricing

GitHub offers free public repository pricing or $7 a month for unlimited personal repositories for personal use. Bitbucket is the Atlassian owned alternative to GitHub, they have free repositories for up to 5 users with 1TB.

Read my Setting up BitBucket on an iMac and creating a project guide.

Read on the differences between GitHub and BitBucket.

Create your first test public Repository. 

Load https://www.github.com and click Start a Project, or go to https://github.com/new

To specify a Readme file and an ignore file if need be (we can do this later). You will need to be a paid Git member to create private repositories.

When your repository is created it will be ready to upload files: https://github.com/SimonFearby/testgitproject001

Creating a local folder

Create a local folder for the repository etc.

# create a folder on your desktop
cd ~/Desktop/
mkdir testgitproject001
cd testgitproject001/

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

# the folder is now ready files from the repository.

Liking the remote repository to the local folder.

First, we need to initialize git locally by typing the following.

git init
> Initialized empty Git repository in /Users/simon/Desktop/testgitproject001/.git/

Now we can add the remote “origin” repository to the local repo.

git remote add origin [email protected]:SimonFearby/testgitproject001.git

We can now see connected remote repositories by typing the following

git remote -v
origin	[email protected]:SimonFearby/testgitproject001.git (fetch)
origin	[email protected]:SimonFearby/testgitproject001.git (push)

Syncing (Pulling) the Repository

Generally, you want to pull all files from the remote repository after you create it (and the readme file).

git pull origin master

This worked 🙂

# What directory are we in
pwd
/Users/simon/Desktop/testgitproject001

# No files
ls -al
total 0
drwxr-xr-x   3 simon  staff   102 28 Jun 00:19 .
drwx------+ 53 simon  staff  1802 28 Jun 00:00 ..
drwxr-xr-x  10 simon  staff   340 28 Jun 00:21 .git

# Let's get the repo files

git pull origin master
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
Unpacking objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
From github.com:SimonFearby/testgitproject001
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master

# Is the readme is there.
ls -al
total 32
drwxr-xr-x   5 simon  staff    170 28 Jun 00:30 .
drwx------+ 53 simon  staff   1802 28 Jun 00:00 ..
drwxr-xr-x  13 simon  staff    442 28 Jun 00:30 .git
-rw-r--r--   1 simon  staff  11357 28 Jun 00:30 LICENSE
-rw-r--r--   1 simon  staff     49 28 Jun 00:30 README.md

Pulling, Pushing, Branches and Forking.

You can read more about pulling, pushing, branches and forking here.

This course helped me https://www.udemy.com/learn-android/

Adding your first local file(s) to the repository

Adding all files to the new directory.

git add -A

Adding a single file:

git add newfilename.txt

Here is an example of adding a new file.

# Create a new file
touch newfilename.txt

#edit the file.
sudo nano newfilename.txt

# Tell git we want this file to be managed
git add newfilename.txt

# What is the status of this repository
git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

Set your default commit username (help)

git config --global user.name "Mona Lisa"

Set your default commit email address (help).

git config --global user.email "[email protected]"

Double-check config here

git config --global --edit

You will need to use vim to insert then save changes. I like the nano text editor better so I am changing the default editor.

Setting your default as nano (and not vim)

nano (and not vim)

git config --global core.editor nano

Submitting (pushing) changes

# Create a new file locally
touch newfilename.txt

# edit the local file
sudo nanonewfilename.txt

# Tell git we want to include it.
git addnewfilename.txt

# commit the file to the remote (origin) server with a commit message
git commitnewfilename.txt -m "addednewfilename.txt"

# Merge all changes with the remote (origin) server
git push origin master

The changes have been pushed (merged)

Adding another file.

This is how I added another single file locally and pushed to the remote (origin) server

# Create a new file locally
touch anothernewfile.txt

# edit the local file
sudo nano anothernewfile.txt 

# Tell git we want to include it.
git add anothernewfile.txt 

# commit the file to the remote (origin) server with a commit message
git commit anothernewfile.txt -m "added anothernewfile.txt"

# Merge all changes with the remote (origin) server
git push origin master

Now we have two new public files in a repository and locally.

README.md and markdown 

Now we need to make the README.MD file look nice and reflect the changes.

More info in markdown formatting here, here, here and here. Here is a good markdown table generator.

I made some changes (see) and pushed to the repository (origin).

# edit the file
sudo nano README.md 

# Tell git we want to commit the changes
git commit README.md -m "edited README.md"

# Merge local changes with the remote repository (origin)
git push origin master

My local README.md markdown changes

# testgitproject001
Simon's Test Git Project 001

# *Added* **two** test __text__ files (~~they are not important~~)

- [x] newfilename.txt
- [x] anothernewfilename.txt
- [ ] notmergedlocalfile.txt

## This is for my (GitHub guide on my blog](https://www.fearby.com/article/setting-up-github-on-an-imac-and-creating-a-project/)

Inline-style: 
![Simon Fearby Avatar](https://fearby.com/Avatar.jpeg "Simon Fearby Avatar")

This is what is looks like on GitHub after I commit and push

You can use pages on GitHub with markdown to create versioned documentation and help.

Commit and check the git status frequently

It is strongly advisable to frequently commit files (to a staging/not master repository) and check local it status for any issues. Commit as frequently as you remember.

# A forgotten local edit
sudo nano README.md 

# Show a gitstatus report
git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   README.md

no changes added to commit (use "git add" and/or "git commit -a")

You can push or delete changes if need be.

Adding many subfolders and many files.

Let’s say you have just added three subfolders (iOS Project Code (12 files), Android Projet Code (1255 items) and a Windows Desktop Project Code (.NET) folder (27 items) and you want to add them all to the remote repository (origin).

Now we need to add the 1,294 files to the local repository.

We can simply type the following to tell git we want it to manage all the local files.

# Add all sub folders and files in tbhis folder.
git add .

# Show a local status report.
simon$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	new file:   .DS_Store
	new file:   Android Project Code/.gitignore
	new file:   Android Project Code/.idea/.name
	new file:   Android Project Code/.idea/compiler.xml
	new file:   Android Project Code/.idea/copyright/profiles_settings.xml
.. 1000+ orther files are listed

Now you can merge the files top remote repository (origin).

git push origin master

Don’t forget to updates your README.md file with changes.

fyi: GitHub may take a minute or two to show changes.

# Edt the README.md
sudo nano README.md 

# Commit the changed file
git commit README.md -m "edited README.md again"

# merge chnages.
push origin master

Ignoring local files

You may want to ignore local files or folders.  In your git folder type.  I like to ignore all files with “secret” in the filename.

AWS recommend you ignore secret keys and logs to prevent inadvertent account access via sharing secret keys.

# Edit your repositories ignore file
sudo nano .git/info/exclude

# Add These exclusions
secret*.*
*secret.*
*secert*.*
*.secret*
*.*secret
*.*secret*

You can find other things to ignore here. You can setup global ignore list by reading this.

You can see I have created a few secret files and new thirdnewfile.txt (and added it to git) and committed and pushed and the secret files remain local (they will remain local while they match the ignored list).

ls -al
total 112
drwxr-xr-x  15 simon  staff    510 28 Jun 15:31 .
drwx------+ 53 simon  staff   1802 28 Jun 14:53 ..
-rw-r--r--@  1 simon  staff  12292 28 Jun 15:00 .DS_Store
drwxr-xr-x  14 simon  staff    476 28 Jun 15:34 .git
drwxr-xr-x  15 simon  staff    510 28 Jun 14:59 Android Project Code
-rw-r--r--   1 simon  staff  11357 28 Jun 00:30 LICENSE
-rw-r--r--   1 simon  staff    544 28 Jun 15:19 README.md
drwxr-xr-x   6 simon  staff    204 28 Jun 15:00 Windows Desktop Project Code
-rw-r--r--   1 simon  staff     10 28 Jun 14:06 anothernewfile.txt
drwxr-xr-x   5 simon  staff    170 28 Jun 14:49 iOS Project Code
-rw-r--r--   1 simon  staff     17 28 Jun 15:30 my.secret
-rw-r--r--   1 simon  staff     10 28 Jun 01:10 newfilename.txt
-rw-r--r--   1 simon  staff     26 28 Jun 15:23 secertapikey.txt
-rw-r--r--   1 simon  staff     22 28 Jun 15:23 secretfile.txt
-rw-r--r--   1 simon  staff     21 28 Jun 15:31 thirdnewfile.txt

GitHub view.

Local Git View

Note the secret files.

GitHub Desktop Application

I checked out the GitHub Desktop application at https://desktop.github.com/.

The downloaded compressed file.

I extracted and copied the app to the Applications folder.

Now I logged into to the application.

Much respect to GitHub for integrating Two Factor Authentication into the login.

Unfortunately, GitHub Desktop thinks I have zero repositories (I have 9 repositories when I log in via the web using the same email address). I contacted support on Twitter but have not had a response yet?

I was able to clone the repository I made via the command line earlier or add a local repository.

I added a new text file (afileaddedwithgithubdesktop.txt) to the folder and GitHub Desktop noticed this new file straight away. I added this file to the repository.

I pushed all local changes to the origin/remote master repository.

All local changes were merged with the remote origin master (I could never do this with Atlassian’s SourceTree application).

Conclusion

Now I can sync up my projects that to GitHub repositories from the terminal and GitHub Desktop application and benefit from the features of git (backups, versioning, rollbacks, multiple machines/multiple users, auto merging etc).

Next

I will add how to pull a repository to a $5 month Digital Ocean and or AWS (Ubuntu) VM.

Read my Setting up BitBucket on an iMac and creating a project guide.

Git repositories on Raspberry Pi’s.

Related guides

Setting up a development environment on Digital Ocean 14.04

https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-14-04

Tips and Troubleshooting

GitHub has a good tips page here.  I had @GitHubHelp pro-actively contact me for support on Twitter. Contact GitHub here.

How to add all local files and commit all local files.

git add -A && git commit

I hope this is helpful to someone.

20 essential git tips. 

P.S Don’t edit live code, use GitHub.

Agile Project Management

Read my blog post on developing software and staying on track here.

I highly recommend you follow Dmitri Iarandine at http://joinagile.com/ (Agile Coach, Trainer, Host of Lean and Mean Agile). Podcast. Author of GET HIRED as SCRUM MASTER).

Dmitri can be found here too.

Soundcloud (Lean and Mean Agile Podcast):
https://soundcloud.com/user-364782318

iTunes:
https://itunes.apple.com/au/podcast/lean-and-mean-agile-podcast/id1269551866

YouTube:
https://www.youtube.com/channel/UC00OZqfM9VmznEOTVzrQQxw

Twitter:
http://twitter.com/iarandine

Udemy:
https://www.udemy.com/agile-coaching-101/

Amazon:
https://www.amazon.com/author/iarandine

Donate and make this blog better




Ask a question or recommend an article
[contact-form-7 id=”30″ title=”Ask a Question”]

v1.7 added info on agile and staying on track,

Filed Under: Git, GitHub Tagged With: add, code, git, merge, pull, push, rfep[ository, rollback, versions

Primary Sidebar

Poll

What would you like to see more posts about?
Results

Support this Blog

Create your own server today (support me by using these links

Create your own server on UpCloud here ($25 free credit).

Create your own server on Vultr here.

Create your own server on Digital Ocean here ($10 free credit).

Remember you can install the Runcloud server management dashboard here if you need DevOps help.

Advertisement:

Tags

2FA (9) Advice (17) Analytics (9) App (9) Apple (10) AWS (9) Backup (21) Business (8) CDN (8) Cloud (49) Cloudflare (8) Code (8) Development (26) Digital Ocean (13) DNS (11) Domain (27) Firewall (12) Git (7) Hosting (18) IoT (9) LetsEncrypt (7) Linux (21) Marketing (11) MySQL (24) NGINX (11) NodeJS (11) OS (10) Performance (6) PHP (13) Scalability (12) Scalable (14) Security (45) SEO (7) Server (26) Software (7) SSH (7) ssl (17) Tech Advice (9) Ubuntu (39) Uncategorized (23) UpCloud (12) VM (45) Vultr (24) Website (14) Wordpress (25)

Disclaimer

Terms And Conditions Of Use All content provided on this "www.fearby.com" blog is for informational purposes only. Views are his own and not his employers. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. Never make changes to a live site without backing it up first.

Advertisement:

Footer

Popular

  • Backing up your computer automatically with BackBlaze software (no data limit)
  • How to back up an iPhone (including photos and videos) multiple ways
  • Add two factor auth login protection to WordPress with YubiCo hardware YubiKeys and or 2FA Authenticator App
  • Setup two factor authenticator protection at login on Ubuntu or Debian
  • Using the Yubico YubiKey NEO hardware-based two-factor authentication device to improve authentication and logins to OSX and software
  • I moved my domain to UpCloud (on the other side of the world) from Vultr (Sydney) and could not be happier with the performance.
  • Monitor server performance with NixStats and receive alerts by SMS, Push, Email, Telegram etc
  • Speeding up WordPress with the ewww.io ExactDN CDN and Image Compression Plugin
  • Add Google AdWords to your WordPress blog

Security

  • Check the compatibility of your WordPress theme and plugin code with PHP Compatibility Checker
  • Add two factor auth login protection to WordPress with YubiCo hardware YubiKeys and or 2FA Authenticator App
  • Setup two factor authenticator protection at login on Ubuntu or Debian
  • Using the Yubico YubiKey NEO hardware-based two-factor authentication device to improve authentication and logins to OSX and software
  • Setting up DNSSEC on a Namecheap domain hosted on UpCloud using CloudFlare
  • Set up Feature-Policy, Referrer-Policy and Content Security Policy headers in Nginx
  • Securing Google G Suite email by setting up SPF, DKIM and DMARC with Cloudflare
  • Enabling TLS 1.3 SSL on a NGINX Website (Ubuntu 16.04 server) that is using Cloudflare
  • Using the Qualys FreeScan Scanner to test your website for online vulnerabilities
  • Beyond SSL with Content Security Policy, Public Key Pinning etc
  • Upgraded to Wordfence Premium to get real-time login defence, malware scanner and two-factor authentication for WordPress logins
  • Run an Ubuntu VM system audit with Lynis
  • Securing Ubuntu in the cloud
  • No matter what server-provider you are using I strongly recommend you have a hot spare ready on a different provider

Code

  • How to code PHP on your localhost and deploy to the cloud via SFTP with PHPStorm by Jet Brains
  • Useful Java FX Code I use in a project using IntelliJ IDEA and jdk1.8.0_161.jdk
  • No matter what server-provider you are using I strongly recommend you have a hot spare ready on a different provider
  • How to setup PHP FPM on demand child workers in PHP 7.x to increase website traffic
  • Installing Android Studio 3 and creating your first Kotlin Android App
  • PHP 7 code to send object oriented sanitised input data via bound parameters to a MYSQL database
  • How to use Sublime Text editor locally to edit code files on a remote server via SSH
  • Creating your first Java FX app and using the Gluon Scene Builder in the IntelliJ IDEA IDE
  • Deploying nodejs apps in the background and monitoring them with PM2 from keymetrics.io

Tech

  • Backing up your computer automatically with BackBlaze software (no data limit)
  • How to back up an iPhone (including photos and videos) multiple ways
  • US v Huawei: The battle for 5G
  • Check the compatibility of your WordPress theme and plugin code with PHP Compatibility Checker
  • Is OSX Mojave on a 2014 MacBook Pro slower or faster than High Sierra
  • Telstra promised Fibre to the house (FTTP) when I had FTTN and this is what happened..
  • The case of the overheating Mac Book Pro and Occam’s Razor
  • Useful Linux Terminal Commands
  • Useful OSX Terminal Commands
  • Useful Linux Terminal Commands
  • What is the difference between 2D, 3D, 360 Video, AR, AR2D, AR3D, MR, VR and HR?
  • Application scalability on a budget (my journey)
  • Monitor server performance with NixStats and receive alerts by SMS, Push, Email, Telegram etc
  • Why I will never buy a new Apple Laptop until they fix the hardware cooling issues.

Wordpress

  • Replacing Google Analytics with Piwik/Matomo for a locally hosted privacy focused open source analytics solution
  • Setting web push notifications in WordPress with OneSignal
  • Telstra promised Fibre to the house (FTTP) when I had FTTN and this is what happened..
  • Check the compatibility of your WordPress theme and plugin code with PHP Compatibility Checker
  • Add two factor auth login protection to WordPress with YubiCo hardware YubiKeys and or 2FA Authenticator App
  • Monitor server performance with NixStats and receive alerts by SMS, Push, Email, Telegram etc
  • Upgraded to Wordfence Premium to get real-time login defence, malware scanner and two-factor authentication for WordPress logins
  • Wordfence Security Plugin for WordPress
  • Speeding up WordPress with the ewww.io ExactDN CDN and Image Compression Plugin
  • Installing and managing WordPress with WP-CLI from the command line on Ubuntu
  • Moving WordPress to a new self managed server away from CPanel
  • Moving WordPress to a new self managed server away from CPanel

General

  • Backing up your computer automatically with BackBlaze software (no data limit)
  • How to back up an iPhone (including photos and videos) multiple ways
  • US v Huawei: The battle for 5G
  • Using the WinSCP Client on Windows to transfer files to and from a Linux server over SFTP
  • Connecting to a server via SSH with Putty
  • Setting web push notifications in WordPress with OneSignal
  • Infographic: So you have an idea for an app
  • Restoring lost files on a Windows FAT, FAT32, NTFS or Linux EXT, Linux XFS volume with iRecover from diydatarecovery.nl
  • Building faster web apps with google tools and exceed user expectations
  • Why I will never buy a new Apple Laptop until they fix the hardware cooling issues.
  • Telstra promised Fibre to the house (FTTP) when I had FTTN and this is what happened..

Copyright © 2023 · News Pro on Genesis Framework · WordPress · Log in

Some ads on this site use cookies. You can opt-out if of local analytics tracking by scrolling to the bottom of the front page or any article and clicking "You are not opted out. Click here to opt out.". Accept Reject Read More
GDPR, Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT