IAC - Version Control
GITHUB
GITHUB
  • Background
  • Setting up GitHub
  • Windows
    • Working with a cloned repo
    • Populating a repo from local files
    • Integrate VSCode
  • Linux
    • Using SSH
    • GH Command Line
  • The Basics
    • Forks
    • Logs
    • Undoing Local Changes
  • Larger Projects
    • Setting up a repo
    • Creating my Branch Architecture Locally
    • Creating a Feature Branch
    • Creating my Branch Architecture on GitHub
    • Merging the changes from GitHub on my local machine
    • Merging the changes from my local machine to GitHub
    • Sync the branches in GitHub
  • Finally
Powered by GitBook
On this page
  1. Windows

Populating a repo from local files

PreviousWorking with a cloned repoNextIntegrate VSCode

Using the web browser, create a new public repo called Exercises

At quick setup I can see the URL.

On your local PC, create a new folder called Exercises and copy some of your Python directories to it.

Open a terminal at this path.

Use git status to see if this is already a repo.

I ran the following commands in sequence to push these files to the GitHub repo. Use the URL to your own Exercises repo.

When I check back on GitHub, I can see that I have pushed my files and directories.

Normally I would have to login with a username and password, but I had already done so.

Note the command git add * and identify what is does. Any directory which was empty did not copy up!

Exercise

Below find a simple Linux shell script I wrote to add all the files in the local directory, commit and push them to the remote origin. The script assumes I have already set up the Git repo.

#!/bin/bash
# by: JOR
# Date: 11DEC18
# Function: Perform a commit
# Script: AddCommitPush.sh

clear
git status

echo '**************************************************'
echo "Performing an add for all files in this directory"
git add .
git status

echo '**************************************************'
echo 'Enter the commit message:'
read CommitMessage
git commit -m "$CommitMessage"
git status

echo '**************************************************'
echo 'Pushing to GITHUB repository'
git push -u origin master
echo '**************************************************'

echo 'Done!'

Firstly, understood what I did (for example, what do you suppose git add . means?). Rewrite this script for windows as a batch file.