-
Notifications
You must be signed in to change notification settings - Fork 4
Bella Woo edited this page Jun 19, 2015
·
5 revisions
Recall Kyle's orange truck analogy:
-
git add <path/to/file>
- puts oranges (files) on the palette -
git commit
- shrinkwrap the palette and put it on a truck- You'll want to configure your editor with git so that commit messages open up in an editor you can use
- You can also
git commit -m "A commit message"
to add a message from the command line and skip the editor
-
git push
- drive the truck to its destination (Github, probably) and drop off the contents- To be more specific you might want to do
git push origin master
(or whatever your branch is) - You'll need to add
-u
(or--set-upstream
) to create the branch on Github the first time you push to a new branch (including the first time you push to master)
- To be more specific you might want to do
Other useful commands
-
git status
- shows what's been added, what's changed, and quick references of what you might want to do -
git log
- shows the history of commits -
git diff
- show exactly what changes have been made since the last commit
-
$ git checkout -b [name_of_your_new_branch]
- Create the branch on your local machine and switch in this branch -
$ git push origin [name_of_your_new_branch]
- Push the branch on github. When you want to commit something in your branch, be sure to be in your branch. -
$ git branch
- You can see all branches created by using this command. Which will show :* approval_messages master master_clean
-
$ git remote add [name_of_your_remote]
- Add a new remote for your branch -
$ git push origin [name_of_your_remote]
- Push changes from your commit into your branch -
$ git fetch [name_of_your_remote]
- Update your branch when the original branch from official repository has been updated -
$ git merge [name_of_your_remote]/develop
- If your branch is derivated from develop you need to do this to apply to merge change. -
$ git branch -d [name_of_your_new_branch]
- Delete a branch on your local filesystem -
$ git branch -D [name_of_your_new_branch]
- To force the deletion of local branch on your filesystem : -
$ git push origin :[name_of_your_new_branch]
- Delete the branch on github. The only difference is the : to say delete, you can do it too by using github interface to remove branch : https://help.github.com/articles/deleting-unused-branches.
For when you didn't mean to push