Follow along!
Have you done any of the following for a project?
What if you need to...
At the highest level, a Git repository is a series of snapshots of files in a folder.
time
Photo credit: gitref.org
There are three sections in a Git repository.
Photo credit: Git-scm.com
Photo credit: CSE 331, UW CSE
git --version
git version 2.X.X"(for Windows users only)
C:\Users\name\AppData\Local\GitHub\PortableGit_<uniqueId>\cmd
git clone git_url
git clone creates a new folder with the same name as your repositoryls to see all files/folders in the current directorycd repoName, replacing repoName with the name of your repository, to navigate to your repoPretend you're working on a project. Maybe you need to:
touch filename
rm filename
vi filename (or use your favorite editor).git diff
git status
git commit -m "your commit message"
git status to see the files to be committed
git log to see all commits made so farasdf
fix bug
yeah
git push
git add files...
git commit -m "message"
git push
git stash and git stash apply
git stash apply to bring back those changesgit checkout -- path1 path2 ...
git reset --hard
git reset HEAD path1 path2 ...
git rm --cached path1 path2 ...
Trick: git status tells you which one to use
git commit --amend -m "new message"
git reset HEAD~1
git reset --hard HEAD~1
Lesson: don't push unless absolutely sure!
git checkout SHA
git log
git checkout master††If you were on a different branch, replace "master" with the branch you were on
git revert SHA
git push
Some files should not be committed:
A file named .gitignore is used to manage this!
touch .gitignore
# Comments start with hash, and are ignored
# A gitignore file is a list of file-matching patterns
# Ignores any file in any directory with this name.
passwords.txt
# Ignores any directory with this name
dist/
# Ignores any file with this extension
*.class
# We can combine file-matching patterns
vendor/*.min.js
Read more: https://git-scm.com/docs/gitignore
cd ..
git clone their_git_url
cd their_repo_name
git add paths...git commit -m "commit message"git pushgit pull
cd ../yourRepoName
git pull.git pull, followed by git push
git mergetool (may require additional software installation)<<<<<<< HEAD
// This is the code that you have written
...
=======
// This is the code that they have written
...
>>>>>>> b56a88aab1e13f7c3402fd71a5f890d0368ea3ec<<<<<, =====, >>>>> should be gonegit add conflicted-file to mark resolutiongit commit to conclude mergegit pushA quick way to say, "their changes are all correct", or "my changes are all correct"
git checkout --theirs file
git checkout --ours file
Along with hosting your Git repository, GitHub provides the following infrastructure:
github.com/username/repo/issues
An issue is a task to accomplish on a project. Examples:
Can't just say "this button doesn't work, plz fix!!"
A good bug report should contain at least:
More overhead, but can help keep your project tidy!
See Mastering Issues
Say you want to contribute to Twitter Bootstrap