Menu Close

Using GIT and GITHUB

What a great tool.   I wish I had dug into this earlier.

There are really two tools

  1. GIT:  According to git-scm.com, “Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.”   It’s a great tool to back up coding work and also provides a way to control versioning allowing you to back up and restore from different points in the development process.
  2. GITHUB:  GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. This tutorial teaches you GitHub essentials like repositories, branches, commits, and pull requests.

Start with specifying your Name and email address.   This is used to identify the user who made last change to an object.

Initialize repository.   Go to directory and use command “git init”

“git status”

2 steps to commit a change to the repository.  1) add files to the staging area with “git add <filename>’, r ‘git add .’ for all files.

then to commit the change to the repository, use the command ‘git commit  -m “commit message”‘.   The commit message is a way to document the changes included in this particular commit or why you are committing this change.

Command ‘git status’ can be used throughout the ‘add’ and ‘commit’ commands.   This will show you the status of all the files within the repository.

Command ;commit; log; is also an interesting command.   This command displays all commits to the repository along with messages specified in each commit.

The benefit of using git is that it enables you to restore your directory back to previous versions of each commit.    For example if you commit your project as it was yesterday and then made significant changes to your code that simly did not work.    You can restore the program back to tyesterday’s commit and start over.   First using the git log command, find the hash tag associated with yesterday’s commit.

Once you have the long hash number, use the ‘git checkout <hash number’ command.

 

Below are the commands used to back up a prject usung git and archiving the project to github:

open terminal and cd to directory

git add .

git commit -m "updated weather_scrape.csv on 12112022"

git push -u origin main

git will ask for user ID and password
user  ID = pbosker and password = token

 

Leave a Reply

Your email address will not be published. Required fields are marked *