工作步骤
- 创建一个远程的空代码库(在BitBucket上)
- 在本地代码库添加一个项目
- 在分支上开发新功能
- a) 保留新功能 或者 b) 丢弃它们
- 也许,回到某个早先的时间点
- 将本地代码库推送到远程代码库
- 在另一台机器上取得远程代码库
安装Git
|
1
|
git
clone
https
:
/
/
github
.com
/
git
/
git
|
创建一个远程代码库
设置Git
|
1
2
|
git
config
--
global
user
.name
"your_username"
git
config
--
global
user
.email
your_email
@
domain
.com
|
|
1
|
git
config
--
global
push
.default
simple
|
创建一个本地代码库
|
1
|
cd
~
/
workspace
/
my_site
/
|
|
1
|
cd
c
:
\
workspace
\
my_site
|
|
1
|
git
init
|
加载(Stage)文件
|
1
|
git
add
.
|
|
1
|
git
add
my_file
,
my_other_file
|
提交文件
|
1
|
git
commit
-
m
"initial commit"
|
|
1
|
git
status
|
创建分支
|
1
|
git
checkout
-
b
new_feature
|
|
1
|
git
branch
new_featuregit
checkout
new_feature
|
|
1
|
git
branch
|
合并分支
|
1
|
git
add
.git
commit
-
m
"adds my new feature"
|
|
1
|
git
checkout
master
|
|
1
|
git
merge
new_feature
|
丢弃分支
|
1
|
git
add
.git
commit
-
m
"feature to be discarded"
|
|
1
|
git
checkout
master
|
删除一个分支
|
1
|
git
branch
-
d
new_feature
|
|
1
|
git
branch
-
D
new_feature
|
回滚到之前的提交状态
|
1
|
git
log
|
|
1
2
3
|
commit
ca82a6dff817ec66f44342007202690a93763949Author
:
your_username
your_email
@
domain
.comDate
:
Mon
Nov
4
12
:
52
:
11
2013
-
0700
changes
the
frontpage
layout
commit
085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7Author
:
your_username
your_email
@
domain
.comDate
:
Mon
Nov
4
11
:
40
:
33
2013
-
0700
adds
my
new
feature
commit
a11bef06a3f659402fe7563abf99ad00de2209e6Author
:
your_username
your_email
@
domain
.comDate
:
Mon
Nov
4
10
:
37
:
28
2013
-
0700
initial
commit
|
|
1
|
git
checkout
085bb3bcb
|
|
1
|
git
checkout
-
b
my_previous
_version
085bb3bcb
|
推送到远程代码库
|
1
|
git
remote
add
origin
https
:
/
/
your_username
@
bitbucket
.org
/
your_username
/
name_of_remote_repository
.git
|
|
1
|
git
push
origin
master
|
取得远程代码库的一份本地拷贝
|
1
|
git
clone
https
:
/
/
your_username
@
bitbucket
.org
/
your_username
/
name_of_remote_repository
.git
|
|
1
|
git
pull
origin
master
|
别名
|
1
|
git
config
--
global
alias
.c
'commit -m'
|
|
1
2
3
4
5
6
7
8
|
git
config
--
global
alias
.c
'commit -m'
git
config
--
global
alias
.co
'checkout'
git
config
--
global
alias
.cob
'checkout -b'
git
config
--
global
alias
.br
'branch'
git
config
--
global
alias
.m
'merge'
git
config
--
global
alias
.a
'add .'
git
config
--
global
alias
.s
'status'
git
config
--
global
alias
.dbr
'branch -d'
|
1万+



被折叠的 条评论
为什么被折叠?



