Introduction to Git & GitHub
Shubhendra S. Chauhan @withshubh
Wait, what is GitHub?
Let me ask you some questions first. - Do you have any kind of coding project? ( It might just be a simple java / c program. ) - Now, If someone asks you to share your code, how will you do it?
Here’s your solution: GitHub let’s you upload all your project files in one particular place.
Let’s, see what we can do with GitHub?
history: Know exactly which files changed, who made those changes, and when those changes occured. backup: Ability to have different versions of the code in different places. collaboration: Collaborate easily with other people on the same codebase
workshop outline
my first git: repositories, staging, committing git good: branching, jumping around, merging git world: enter in the repository world git ideas: cool stuff to do with git open sourcing: the idea that it’s a changing.
$ terminal commands are typed with this font and color. before we begin...
don’t worry! there is always a cheat sheet!
my first git Create your shiny repo and your first commit.
what is a repository? A repository is like any other folder on your computer, it can contain any type of file and works in exactly the same way… Except: It has a hidden file named ".git" that stores the history of that folder
Let's take a look at
first, install git
second, start a new repository by $ git init <repository name>
what are commits? snapshots of the state (e.g. code) of your repository
commit your work by using $ git add . $ git commit -m “<details>”
more about commits Bc7fd9 “Add Oranges” a3ffde “Add apples” 9cd1ce “First commit, Add fruit.txt” Commits forms a linked list structure which shows what you have done over time. Use git log to see your commit history.
staging changes Unstaged Changes Staged Changes Committed Changes git add git commit git reset <hash>git reset .
my first git: recap $ git init - converts a folder to a super smart git repository. $ git add - adds the files you want to be tracked to the staging area. $ git commit - creates a new snapshot of your repository at that point in time. $ git reset - Undo your commit or unstage your files. $ git log - View your commit history. $ git status - See the current status of your repository
Let's take a look at
git good branching, context switching, merging
Bc7fd9 “Add oranges” a3ffde “Add apples” 9cd1ce “First commit, Add fruit.txt” commits
working with branches $ git branch - see a list of all available branches. $ git branch <branchname> - create a new branch with the desired name, based on the current branch.
Bc7fd9 “Add oranges” a3ffde “Add apples” 9cd1ce “First commit, Add fruit.txt” master commits branches
working with HEAD $ git checkout <branch name> - Redirect HEAD to the desired branch
Bc7fd9 “Add oranges” a3ffde “Add apples” 9cd1ce “First commit, Add fruit.txt” master commits branches HEAD HEAD somebranch
merging = combining commits $ git merge <branch name> - creates a new commit that combines the last commit of the current HEAD branch with the last commit of the desired branch.
git good: recap... $ git branch - List all branches $ git branch <name> - creates a branch with that name $ git checkout <name> - jump to the branch with this name $ git merge --no-ff <name> - merge the branch with this name into the current one.
git world publishing, updating and downloading
Let's take a look at
downloading / updating Repos $ git clone <url> - downloads a copy of a remote git repository. $ git pull - performs a merge of what you have on your computer with what's on the server. $ git push - sends your version to the server.
git ideas a quick look at what other folks are doing on
Host your personal page for free on
Collections on open and explore the vast world of repositories that exist. I'm sure you'll be surprised! Social Impact Learn to Code Organizations Open Journalism and much more...
#OpenSourcing Understand more about the movement that is changing the way you collaborate.
and many others ... Communities on open and explore communities that do a change in the open source world. and much more...
Events on open and participate in events that happens around the world in prol of the open source. and much more... 24 Pull Requests Hacktoberfest GitHub Field Day
time to get our hands dirty!
Doubts? Suggestions? Feedback? Your opinion is worth gold stickers!
Let's take a picture? Share on social networks and check @withshubh #githubeducation #githubcampusexperts
Thank you! @withshubh /in/withshubh
git & GitHub workshop

git & GitHub workshop