I stated learning ruby on rails .
Reference book (Rails 101)
First of all , I started to learn the basic operation of github (
https://github.com/)
I learned from the website(
http://try.github.io/levels/1/challenges/1)
Got 15 minutes and want to learn Git?
1.git init
To initialize a Git repository
2.git status
see what the current state of our project is
3.git add filename
add file to the staging area by using git add
4.git commit -m "註解"
To store our staged changes we run the commit
command with a message describing what we've changed.
5.git add "*.txt"
adding all changes
6.git log
look history
7.git remote add origin repository URL,
setting remote repository url(GitHub url by your account)
8.git push -u origin master
The name of our remote is origin
and the default local branch name is master
The -u
tells Git to remember the parameters, so that next time we can simply run git push
and Git will know what to do.
9.git pull origin master
pull file from origin
10.git diff HEAD
look at what is different
from our last commit by using the git diff
command
HEAD
:want the diff of our most recent commit
11.git diff --staged
run git diff
with the --staged
option to see the changes you just staged
12.git reset filename
You can unstage files by using the git reset
command
13.git checkout -- <target>
Files can be changed back to how they were at the last commit by using the command
Restore the deleted files
14.git branch branchname
When developers are working on a feature or bug they'll often create a copy (aka. branch
) of their code they can make separate commits to. Then when they're done they can merge this branch back into their main master
branch.
15.git branch
you can see a main branch named master
and your others branch named
16.git checkout branchname
You can switch branches using the git checkout <branch>
command
17.git remove
remove all the things
18.git merge branchname
We're already on the master
branch, so we just need to tell Git to merge the branchname branch into it:
19.git branch -d branchname
delete a branch.