Lecture 1 Notes
Lecture 1 Notes
Introduction
Git
GitHub
Commits
Merge Conflicts
Branching
o More GitHub Features
Introduction
Welcome back to lecture 1! In lecture 0, we introduced HTML, CSS,
and Sass as tools we can use to create some basic web pages.
Today, we’ll be learning about using Git and GitHub to help us in
developing web programming applications.
Git
Git is a command line tool that will help us with version
control in several different ways:
o Allowing us to keep track of changes we make to our
code by saving snapshots of our code at a given point in
time.
Commits
Now, we’ll start to get into what Git can be really useful for.
After making some changes to a file, we can commit those
changes, taking a snapshot of the current state of our code.
To do this, we run: git commit -m "some message" where the
message describes the changes you just made.
After this change, we can run git status to see how our code
compares to the code on the remote repository
When we’re ready to publish our local commits to Github, we
can run git push. Now, when we go to GitHub in our web
browser, our changes will be reflected.
If you’ve only changed existing files and not created new
ones, instead of using git add . and then git commit..., we can
condense this into one command: git commit -am "some
message". This command will commit all the changes that you
made.
Sometimes, the remote repository on GitHub will be more up
to date than the local version. In this case, you want to first
commit any changes, and then run git pull to pull any remote
changes to your repository.
Merge Conflicts
One problem that can emerge when working with Git,
especially when you’re collaborating with other people, is
something called a merge conflict. A merge conflict occurs
when two people attempt to change a file in ways that conflict
with each other.
This will typically occur when you either git push or git pull.
When this happens, Git will automatically change the file into
a format that clearly outlines what the conflict is. Here’s an
example where the same line was added in two different
ways:
a=1
<<<<< HEAD
b=2
=====
b=3
>>>>> 56782736387980937883
c=3
d=4
e=5
There are some useful features specific to GitHub that can help
when you’re working on a project: