Skip to content

Instantly share code, notes, and snippets.

@foster55f
Last active June 1, 2019 21:29
Show Gist options
  • Save foster55f/93e47cea55d26603850c8e51dd3c0ec8 to your computer and use it in GitHub Desktop.
Save foster55f/93e47cea55d26603850c8e51dd3c0ec8 to your computer and use it in GitHub Desktop.

A Beginners Guide to Git

A Beginners Guide to Git

Gives Software Developers the tools to be able to work on a project at the same time

  1. Git is a version control system
  • Used for managing the changes to a project over time.
  • Git allows you to decide exactly when you save a version of a project
  1. GitHub is the website that hosts the Git Repos (folders with Git tracking) online, making it easier to share.
  • Repositories (Repos) are folders which contain intentional snapshots of progress called commits.

To get started with Git you need to start by having a GitHub account. Then you would open a new Repo on GitHub to store your project. GitHub would then provide you with a page giving instructions on how to connect to the GitHub Repo. This would be an origin (URL) that gives location of your Repo. To be able to connect to this GitHub Repo through Terminal, you need to have initialized (git init) a Git repo (working directory) on your computer to connect to the GitHub Repo. You need to be in the (cd working directory) on your terminal while connecting(git remote add origin). This(git remote add origin) tells git that I want to add a remote Repo that lives at this origin (URL). If you had committed (git commit -m) changes already to your local repo then Git would be tracking your changes. At this point, you are ready to push(git push -u origin master)the changes up to the origin and into the master (branch, default name for branch of your new GitHub repo).

fostertaylor~[master ?+]$ ls
Applications		Movies			git_homework
Beginners_Guide_to_Git	Music			git_practice
Desktop			Pictures		open
Documents		Public			quotes.txt
Downloads		README.md		to_do
Library			best_animals
fostertaylor~[master ?+]$ cd Beginners_Guide_to_Git
fostertaylor~/Beginners_Guide_to_Git[master ?+]$ git init
Initialized empty Git repository in /Users/fostertaylor/Beginners_Guide_to_Git/.git/
fostertaylor~/Beginners_Guide_to_Git$ touch guide.txt
fostertaylor~/Beginners_Guide_to_Git$ ls
guide.txt
fostertaylor~/Beginners_Guide_to_Git$ git add .
fostertaylor~/Beginners_Guide_to_Git$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

	new file:   guide.txt

fostertaylor~/Beginners_Guide_to_Git$ git commit -m 'Initial commit'
[master (root-commit) 2113d4c] Initial commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 guide.txt
fostertaylor~/Beginners_Guide_to_Git[master]$ git remote add origin https://github.com/foster55f/Beginners_Guide_to_Git.git
fostertaylor~/Beginners_Guide_to_Git[master]$ git push -u origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 223 bytes | 223.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/foster55f/Beginners_Guide_to_Git.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
fostertaylor~/Beginners_Guide_to_Git[master]$ 

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment