-
Notifications
You must be signed in to change notification settings - Fork 0
Helpful Git Information
Emma Sax edited this page Sep 27, 2015
·
1 revision
As you make your way through the Hands-On-Git section and the Work Time section of Open Hatch, you might find the following handy:
- Fork: button near top right corner of a repository; creates your own copy of the repository that you can edit independently from the original.
- Clone: brings a copy of a repository onto your local machine.
- Pull Request: a way to ask to merge your changes to a repository back into the original; the changes could've occurred in a fork of a repository or in a separate branch of the repository.
- Commit: a special snapshot of your repository; each commit has its own sha (or its one-time-only identification hash)
- Index: the place where you keep all of the files you eventually want to commit.
-
git pull
orgit pull origin <branch-name>
: updates your local version of a repository with the updated version on GitHub; automatically fixes any merge conflicts. -
git fetch
: basicallygit pull
without automatic fixing of merge conflicts. -
git clone <url>
: brings a copy of a repository on GitHub to your local machine. -
git status
: gives you the current status of the files in the repository on your local machine, AKA, what has been added new, deleted, or modified. -
git diff
: shows you the changes since your last commit. -
git add <file-name>
orgit add -A
: adds any files that are or are not already being tracked by GitHub to your git index. -
git commit -m "Helpful commit message"
: tells Git to remember the current state of all of your files; the flag-a
is optional, read more about that here. -
git push
orgit push origin <branch-name>
: pushes your local commits onto GitHub. -
git remote -v
: see where your local repository is pulling from and pushing to. -
git remote add <name-of-remote> <url-of-remote>
: add another remote (really good for when you wish to update your local repository with not only your fork of a repository, but also with what repository you forked yours from). -
git branch
: list all local branches in your repository. -
git branch -d
: delete a local branch -
git push origin <remote-branch-name>
: after deleting locally, run this to delete the branch remotely, too. -
git checkout <branch-name>
: switch locally from one branch to another local branch. -
git merge <branch-name>
: merges a different branch of your repository into your branch -
git init
: create a new local Git repository. -
git config --global user.name "Firstname Lastname"
: tell Git through your terminal who you are. -
git reset --hard origin/<branch-name>
: drop all local changes and commits, and refresh back to what's currently on GitHub.