第一次使用Git
特別注意:
對(duì)于首次安裝git的機(jī)器,一定要首先進(jìn)行用戶(hù)賬戶(hù)信息的配置,如下:
git config --global user.name "你的github用戶(hù)名"
git config --global user.email "你的github郵箱地址"
1、使用 git 之前先添加 SSH key
具體方法參考:GitHub 添加 SSH key 的方法
2、上傳文件到 GitHub
運(yùn)行 git bush,輸入:
mkdir test
cd test
git init
touch README
git add README
git commit -m'first commit'
git remote add origin git@github.com:lzjun/test.git
git push -u origin master
然后登陸 GitHub ,查看是不是有剛上傳的文件。
補(bǔ)充:
commit 的時(shí)候如果發(fā)生亂碼,可以設(shè)置global全局變量:
git config --global i18n.commitencoding utf-8
3、Fork 別人的項(xiàng)目
如果想下載名為username用戶(hù)的項(xiàng)目,我們需要使用clone命令,假設(shè)項(xiàng)目名叫“tools",輸入:
git clone git@github.com:username/tools.git
4、上傳文件到github
運(yùn)行g(shù)it bush,依次輸入:
git add xxxx.py
git commit -m '上傳/修改文件說(shuō)明信息'
git push