1贝次、本地安裝git環(huán)境
????下載安裝包安裝即可
2崔兴、初始化git項(xiàng)目,生成 .git 配置目錄
????進(jìn)入項(xiàng)目根目錄,右鍵 git bash here打開控制臺(tái) 蛔翅,輸入git init即可完成
3敲茄、將項(xiàng)目加入本地git倉庫
????git add . (此處add后面有空格 和點(diǎn)號(hào))
????git status
????touch README.md (可不要
????git add README.md (可不要
????git commit -m "first commit"
4、在git山析、碼云建好云端項(xiàng)目堰燎,生成git url
????建好項(xiàng)目,在項(xiàng)目的克隆下載處復(fù)制url即可
5笋轨、連接云端倉庫,將本地倉庫代碼提交到云端倉庫
????連接云端倉庫
????git remote add origin?https://gitee.com/xxx/xxx.git
????為解決本地與云端版本沖突秆剪,加上-f參數(shù),push文件
????git push --set-upstream origin master -f
????之后會(huì)提示輸入云端倉庫的用戶名爵政,密碼仅讽,驗(yàn)證成功開始上傳并完成,實(shí)測(cè)碼云可通過
????不加f會(huì)提示錯(cuò)誤:
????! [rejected] master -> master (non-fast-forward)
????error: failed to push some refs to 'https://gitee.com/xxx/xxx.git'
????hint: Updates were rejected because the tip of your current branch is behind
????hint: its remote counterpart. Integrate the remote changes (e.g.
????hint: 'git pull ...') before pushing again.
????hint: See the 'Note about fast-forwards' in 'git push --help' for details.
????到此就完成了目的钾挟。
以后每次提交是先提交到本地倉庫何什,
需重新運(yùn)行?git push --set-upstream origin master -f
更新到云端
或是commit 后 push
push
git 修改用戶名,郵箱:
當(dāng)前 project:
直接修改 .git目錄下 config文件的
[user]
name =xxx
email = xxx
或
git config user.name 用戶名;
git config user.email 郵箱;
全局:
git config ?--global user.name 用戶名等龙;
git config ?--global user.email 郵箱名;