使用gitee(碼雲)創建代碼倉庫


安裝git:https://git-scm.com/downloads

1、在gitee中新建一個倉庫

2、在本地項目文件夾中運行命令

git status

如果出現:fatal: not a git repository (or any of the parent directories): .git  這個錯誤,則需要運行命令

git init

此時出現 Initialized empty Git repository in ****.git/  表示成功,再次重復第一個命令

若有文件沒有同步則使用命令:

git add .  將文件添加至暫存區
git commit -m "完成了登錄功能" 將暫存區代碼提交至本地倉庫 “完成了登錄功能”是更新的日志
 完成后輸入
git status
 查看結果顯示如下表示成功

On branch master

    nothing to commit, working tree clean

 

3、輸入命令將本地代碼同步到雲倉庫

git remote add origin https://gitee.com/***/***.git
git push -u origin master

4、創建分支(login 為分支名稱)

git checkout -b login

5、查看所有分支

git branch

 6、將(login)分支代碼合並至master主分支

git checkout master  切換至master主分支
git merge login 將login分支代碼合並至master主分支

7、將本地master主分支代碼提交到雲倉庫

git push

8、將本地分支login代碼提交至雲倉庫

git checkout login  先切換至login分支
git push -u origin login 首次提交寫法,因為雲端沒有login分支

 9、第一次完整下載代碼倉庫

git config --global user.name "你的用戶名"
git config --global user.email "你的郵箱"
git init
git remote add origin 倉庫地址  //注:項目地址形式為:https://gitee.com/xxx/xxx.git或者 git@gitee.com:xxx/xxx.git
git pull origin master

//////////////////////
//下載指定分支
git init 進行初始化
git remote add origin 代碼倉庫地址 //與遠程代碼倉庫建立連接:
git fetch origin dev(dev即分支名) //將遠程分支拉到本地
git pull origin dev(dev為遠程分支名) //將遠程分支拉取到本地

10、修改后提交更新

git add .  將文件添加至暫存區
git commit -m "完成了**功能"  
git push

若提示
hint: Updates were rejected because the remote contains work that you do

  git pull origin master

  git push -u origin master

11、下載更新

 git pull -u origin master:master。//從指定分支更新
 git pull 更新默認分支

  若提示

  Your local changes would be overwritten by merge

  git reset --hard

  git pull

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM