工作步骤
- 创建一个远程的空代码库(在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'
|
最新评论
你也可以签出到一个新的分支,像这样:
git checkout -b my_previous_version 085bb3bcb
这里的“签”应该是“迁”啊?
赞
@人微言轻 当然是“签”了。
Stage怎么会翻译成“加载”的?
赞
之前搜索了一下,似乎没有特别主流的中文译法,看到叫过叫加载,或者索引,似乎觉得加载更形象一点,所以括号里也留着stage英文。
现在直接去找“暂存”,还是能找到不少的。看来"暂存"似乎更合理一些。
赞
不错!
赞
branch分支那段讲得挺好的!
赞
感谢LZ,亲自试用了,非常好,最后
取得远程代码库的一份本地拷贝 那里的命令有点小错
git clone https://your_username@bitbucket/your_username/name_of_remote_repository.git
应该是
git clone https://your_username@bitbucket.org/your_username/name_of_remote_repository.git
赞
谢谢提醒,已修改。:)
赞
nice,很不错呀。
赞
请问上传了本地代码库到SAE的远程代码库,为什么打开应用网址,却是空白呢?
赞