Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jowtow/HowToGitGit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

HowToGitGit

A Beginner's Guide to Git

Aim to answer/accomplish these questions/tasks.

  • What is Git?
  • Why use Git?
  • What is GitHub?
  • Let's make a repo
  • Let's clone that repo
  • Let's add some files and make a commit
  • Let's branch
  • Let's merge that branch back to master
  • Let's show how I can pull those changes on another computer
  • Some useful commands
  • Let's review

What is Git?

       Git is a source control system that allows for historical snapshotting of files and sharing of those files amongst one or more people. Basically it's Google Drive with the ability to snapshot your file changes (but with so, so much more). This allows you to better keep track of changes in a filebase, give yourself access to your files from any machine with access to the internet, and the ability to implement new features to a repository without stepping on your fellow collaborator's toes. Also, Git was created by Linus Torvalds in 2005 for development of the Linux kernel, so there is your ethos appeal.

  • What is Git?

Why use Git?

       It will make your life as a developer (or just user of files) easier. Sure you have to learn some stuff, but once you do, you will have the ability to control your codebase in a centralized, backed up, and efficent way. On top of that, knowledge of git increases your employability. Every real world developer position you will find will utilize some form of source control. If they don't, I would encourage you to seek opportunities elsewhere. Haven't convinced you yet? GIT IS FREE! and there are tons of free git hosting services.

       While git is awesome, it isn't the only Version Control System out there. Some other ones include Apache Subversion (SVN) and Mercurial, or Microsoft's Team Foundation Version Control. I don't know much about these, but as far as popularity via Google search goes, Git reigns supreme.

gitmetrics

  • Why use Git?

What is GitHub?

       Well now that we have an idea of what Git is, we need to talk about git hosting platforms. Git hosting platforms are what make Git as a technology available on the web. Without some sort of centralized server/hosting platform, Git would only give you the ability to snapshot and divide your filebase locally. All of the sharing capabilities and bells and whistles come from a hosting platform. Github is among the most popular of these platforms. Github currently hosts more than 28 million users, more than 85 million repositories, and is home to many prestigious open source projects.

prestigiousProjects

  • What is GitHub?

LIVE DEMO

Let's Make a Repository!

       A repository is just the directory that has all of your files you would like to version control. It is easiest to create a new one from GitHub online.

  • Let's make a repo

Let's Clone it!

       Cloning is essentially just like downloading a repo. It takes the code from the server and makes a copy on your own machine. The special thing about cloning is that you are able to send changes back to the server more easily and elegantly.

Most easily done from GitHub online or GitHub Desktop

If we ever need to update our local version of the repo, we do so using a pull.

Commands:
git pull // get latest version of current branch from server

  • Let's clone that repo

Let's add some files and commit!

       Once you have cloned your repository, you can now CRUD (create, read, update, delete). Once you have flung some CRUD, your next goal is to get it back out to the server! Since the changes we made are all local, we must do a commit and push. The "commit" portion is just saving all the operations you have done locally, this allows you to organize your changes as well, by putting changes in respective commits. The "push" portion is what actually sends your changes to the server (GitHub).

Can easily do this on GitHub Online or GitHub Desktop

To complete this from the command line we:
git add [filename] // Add file to the commit
git commit -m [commitMessage] // Commit our changes with a message, without opening VIM
git push // Send this commit to the remote branch (at this point our branch is just master)

  • Let's add some files and make a commit

Branching!

       Up until this point, we have only been making changes on 1 branch, the master branch. Generally when working features, we make branches off of our main codebase (master). In these branches we can make many commits and pushes but never change our main, working codebase (master).

There are many ways to work with branches in GitHub Online and Desktop, but most of the time, the command line is the most useful.

Commands:
git branch // lists all branches
git branch [nameOfBranch] // makes new branch named as specified
git checkout [nameOfBranch] // switches to the branch specified
git checkout -b [nameOfNewBranch] // creates a new branch with the name specified and switches to it
git branch -D [nameOfBranch] // deletes the branch specified

  • Let's branch

When we are convinced that we have completed a feature, we want to get our changes from our branch into master. We do this either by making a merge or a pull request. These two methods basically take all of the files we have changed in our branch, and seemlessly add our changes to the master branch. Pull requests are specific to GitHub and allow you to set some more rules and reviews before "merging" a branch into master, this is especially useful when using Git in a team.

Commands:
git merge [branchName] // merges the code from the specified branch into the current branch

  • Let's merge that branch back to master

Collaboration!

  • Let's show how I can pull those changes on another computer

Other Useful commands

Commands:
git init // initialize a new repo
git clone [repoName] // clone a preexisting repo
git status // lists all changes in your current branch
git stash // move your current commits to a stash where you can later pop them off

  • Some useful commands

Review

  • Let's review

Resources

Markdown Cheatsheet
I learned how to make this readme here.

About

A repo for my presentation on git for DSU Computer Club

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •