Git和Bitbucket入門之代碼上傳

作爲一名代碼渣,雖然代碼寫得很爛,但多多少少也寫了些了。聽說大牛們都在用Bitbucket,瞻仰代碼時卻連git clone都不會也有點說不過去了,因此,我要入門!

參考:http://blog.jobbole.com/53573/ (中文)
https://confluence.atlassian.com/bitbucket/bitbucket-cloud-documentation-home-221448814.html(英文)

1、安裝git https://git-scm.com/
2、註冊用戶並創建一個倉庫 https://bitbucket.org
3、設置git

git config --global user.name "your_username"
git config --global user.email your_email@domain.com    
git config --global push.default simple

4、創建本地代碼庫
在工程文件夾內,右鍵git bash here,彈出命令行模式

git init

創建一個名爲.git的隱藏文件夾,那就是本地代碼庫。

5、加載文件

git add .

“.”代表根目錄下的所有文件,也可以指定某個文件。
6.提交文件

git commit -m “first try”

提交併註釋

7、上傳至遠程代碼庫
添加遠程代碼庫

git remote add origin https://your_username@bitbucket.org/your_username/name_of_remote_repository.git

origin是代碼庫的別名,可以自己規定。

git push origin master

推送。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章