您好,登錄后才能下訂單哦!
git init # 創(chuàng)建本地倉庫 # 設(shè)置遠程倉庫地址,這里可以設(shè)置ssh 或 https 的形式,此處設(shè)置為https 格式, # ssh 格式為 : git remote add origin git@coding.net:sql031625/test.git git remote add origin https://git.coding.net/sql031625/test.git touch a.py # 創(chuàng)建文件,使倉庫有新的變更 git add . # 添加所有變更 git commit -m 'first' # 注釋 git push -u oringin master # 推送代碼,第一次使用 -u ,以后便可以不使用 -u 參數(shù) # 可以設(shè)置 git config --global push.default matching命令,使得push命令默認push到github的同名倉庫中
若最后一步出錯,
ralap@Ubuntu:~/data/coder/webtest$ git push -u origin master Username for 'https://git.coding.net': sql031625 Password for 'https://sql031625@git.coding.net': To https://git.coding.net/sql031625/test.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://git.coding.net/sql031625/test.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
原因分析:在github上重新創(chuàng)建倉庫,建立README.md,導(dǎo)致該文件不在本地代碼中,執(zhí)行以下命令,將git 倉庫中的文件與本地合并,然后再上傳即可
git pull --rebase origin master git push -u oringin master
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。