設(shè)置基本信息。
git config --global user.name "yourname"
git config --global user.email "youremail@youremail.com"
初始化本地庫
將你的遠程倉庫克隆到本地犬耻,或者你可以在本地初始化一個項目后再進行云端綁定站削。
- 直接從遠程倉庫克隆到當前文件夾,自動在當前文件夾下創(chuàng)建項目文件夾
git clone https://gitee.com/yourname/repository.git
yourname 您在碼云或gitee注冊的用戶名
repository 您創(chuàng)建的遠程倉庫名稱
- 本地初始化隶症,自己創(chuàng)建并進入項目文件夾
//首先在文件系統(tǒng)中創(chuàng)建一個項目文件夾,然后在Git中 cd 到這個工程目錄
cd <文件夾>
//初始化本地項目
git init
//綁定遠程倉庫
git remote add origin <遠程倉庫地址>
注:地址形式為 https://gitee.com/yourname/test.git
注:origin就替換了 https://gitee.com/yourname/test.git
更新到遠程倉庫
//指定更新內(nèi)容 . 表示全部更新岗宣,test.txt 表示更新指定文件
git add .
//添加更新說明
git commit -m "一些注釋說明"
//執(zhí)行更新操作
git push origin master
從遠程倉庫同步最新版本到本地
cd /d/test
git pull origin master
git常用命令
//用于查看提交日志
git log
//單行查看commit日志
git log --pretty=oneline
//查詢綁定的遠程倉庫
git remote -v
//回到上個commit版本桥言,一個^表示回退一個版本罩引,可添加多個
git reset --hard HEAD^
//回到某個commit版本
git reset --hard commitID
//查看每一次git操作惦积,一般用于尋找commit id
git reflog
1.添加用戶名和git賬號郵箱
git config --global user.name "username"
git config --global user.email "youremailname@youremail.com"
2.初始化本地項目
cd <文件夾>
git init
3.設(shè)置綁定遠程倉庫
git remote add origin <遠程倉庫url>
4.刪除遠程倉庫
git remote rm origin/<遠程倉庫url>
5.推送代碼到遠程倉庫
git add .
git commit -m "一些注釋說明"
git push origin/<遠程倉庫url> master
6.從遠程倉庫拉取代碼
git pull origin/<遠程倉庫url> master
7.git pull 錯誤 :error: The following untracked working tree files would be overwritten by merge:
.DS_Store.Please move or remove them before you merge.
git clean -d -fx
8.git stash 暫存修改的代碼五芝,然后進行 git pull ,再解封暫存的代碼 git stash apply --index
參考鏈接:https://www.cnblogs.com/yiven/p/8465054.html