Git 기본 튜토리얼
힘내 튜토리얼
Git 명령 影響範圍
Gitlab 專案初始化
명령줄 지침
Git 전역 설정
git config --global user.name "Corey Lai"
git config --global user.email "[email protected]"
새 저장소 만들기
git clone http://gitlab/ws/wsrm-react-ide.git
cd wsrm-react-ide
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
기존 폴더
cd existing_folder
git init
git remote add origin http://gitlab/ws/wsrm-react-ide.git
git add .
git commit -m "Initial commit"
git push -u origin master
기존 Git 저장소
cd existing_repo
git remote add origin http://gitlab/ws/wsrm-react-ide.git
git push -u origin --all
git push -u origin --tags
創建
在local端建立一個
$ git init
從gitlab內載入已經建立的庫
$ git clone http://gitlab/zk/deplm.git
현지 端操作
顯示目前已修改文件
$ git status
顯示與上次提交版本不同處
$ git diff
將修改檔案加入index
# 所有修改進行提交
$ git add .
# 指定特定文件進行提交
$ git add -p{patch 批次確認} <filename>
# 解決衝突後,將檔案標記為以解決
$ git add <resolved-filename>
提交更改
$ git commit -a{略過 git add 步驟}
$ git commit -m "comment"
$ git commit --amend {撤回提交}
자식 역사
顯示歷程
$ git log
#顯示指定檔案所有修改
$ git log -p <filename>
分支
자식 분기
# 顯示所有分支
$ git branch -av
# 基於當前分支創建新分支
$ git branch <new-branch>
# 刪除本地分支
$ git branch -d <branch>
# 刪除遠端分支
$ git branch -dr <branch>
자식 태그
給當前提交設標籤
$ git tag <tag-name>
更新與發佈
자식 원격
# 列出遠端庫
$ git remote -v
# 新增遠端庫
$ git remote add <nickname> <url>
자식 가져오기
# 取得遠端庫所有變動,不合併到local
$ git fetch <remote>
#
자식 풀
# 取得遠端庫所有變動,不合併到local
$ git pull <remote> <branch>
$ git pull origin development
合併
자식 병합
# 將當前分支合併到指定分支
$ git merge <branch>
자식 리베이스
# 將當前分支重新接枝到指定分支
$ git rebase <branch>
# 終止rebase
$ git rebase --abort
# 解決衝突後繼續重新接枝
$ git rebase --continue
撤銷
자식 리셋
# 放棄目前所有修改
$ git reset --hard HEAD
# 回到指定commit,並將之後修改標記
$ git reset <commit>
# 放棄目前所有修改,並回到指定commit
$ git reset --hard <commit>
# 回到指定commit,並保留local尚未提交的修改
$ git reset --keep <commit>
# 取消已 add file
$ git reset HEAD <filename>
자식 되돌리기
# 回到前一次 commit 的狀態
$ git revert HEAD
本機憑證快取
記憶憑證
git config credential.helper store
清除憑證
git config --global --unset credential.helper
git config --system --unset credential.helper
힘내 체크 아웃
Git 從特定 분기 取得特定檔案
$ git checkout <another-branch> <path-to-file> [<one-more-file> ...]
$ git status
$ git commit -m "'Merge' specific file from '<another-branch>'"
Git 標準流程
如專案已從 Gitlab 上下載並開發完成請從 Step 5. 開始
# Step 1.
$ git clone http://gitlab/zk/<project>.git
# Step 2.
$ git checkout development
# Step 3.
$ git pull
# Step 4.
Coding ...
# Step 5.
$ git add <file> or . {all file that was changed}
# Step 6. check the files you add
$ git status
# Step 7.
$ git commit -m "comment"
# Step 8.
$ git push origin development
# Step 9. git conflict happen
Resolve...
# Step 10. git conflict happen
$ git add <resolved-file>
# Step 11.
$ git push origin development
Git 병합 분기
$ git checkout release
$ git merge development
$ git add .
$ git push
### forced update
$ git checkout release
$ git reset --hard development
$ git push --force origin release
힘내 기능
1. 오리진/마스터 브랜치를 기능 브랜치에 병합
# step1: change branch to master, and pull to update all commits
$ git checkout master
$ git pull
# step2: change branch to target, and pull to update commits
$ git checkout feature
$ git pull
# step3: merge master to feature(⚠️ current is feature branch)
$ git merge master
2. 기능 브랜치를 오리진/마스터 브랜치에 병합
$ git checkout master
$ git pull origin master
$ git merge feature
$ git push origin master
.gitignore 파일
git rm -r --cached .
git add .
git commit -m ".gitignore"
자식 분기
특징
# create feature
git checkout -b desc-feature master
git status
git add <some-file>
git commit
# finish dev
git push -u origin desc-feature
git push
# merge master
git checkout master
git pull
#git pull origin desc-feature
git merge desc-feature
git push
git branch -d desc-feature
힘내 모듈
git submodule add <repository> [<path>]</path></repository>
Reference
이 문제에 관하여(Git 기본 튜토리얼), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://dev.to/hyperredstart/git-tutorial-3o6b
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
git config --global user.name "Corey Lai"
git config --global user.email "[email protected]"
git clone http://gitlab/ws/wsrm-react-ide.git
cd wsrm-react-ide
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
cd existing_folder
git init
git remote add origin http://gitlab/ws/wsrm-react-ide.git
git add .
git commit -m "Initial commit"
git push -u origin master
cd existing_repo
git remote add origin http://gitlab/ws/wsrm-react-ide.git
git push -u origin --all
git push -u origin --tags
$ git init
$ git clone http://gitlab/zk/deplm.git
$ git status
$ git diff
# 所有修改進行提交
$ git add .
# 指定特定文件進行提交
$ git add -p{patch 批次確認} <filename>
# 解決衝突後,將檔案標記為以解決
$ git add <resolved-filename>
$ git commit -a{略過 git add 步驟}
$ git commit -m "comment"
$ git commit --amend {撤回提交}
$ git log
#顯示指定檔案所有修改
$ git log -p <filename>
# 顯示所有分支
$ git branch -av
# 基於當前分支創建新分支
$ git branch <new-branch>
# 刪除本地分支
$ git branch -d <branch>
# 刪除遠端分支
$ git branch -dr <branch>
$ git tag <tag-name>
# 列出遠端庫
$ git remote -v
# 新增遠端庫
$ git remote add <nickname> <url>
# 取得遠端庫所有變動,不合併到local
$ git fetch <remote>
#
# 取得遠端庫所有變動,不合併到local
$ git pull <remote> <branch>
$ git pull origin development
# 將當前分支合併到指定分支
$ git merge <branch>
# 將當前分支重新接枝到指定分支
$ git rebase <branch>
# 終止rebase
$ git rebase --abort
# 解決衝突後繼續重新接枝
$ git rebase --continue
# 放棄目前所有修改
$ git reset --hard HEAD
# 回到指定commit,並將之後修改標記
$ git reset <commit>
# 放棄目前所有修改,並回到指定commit
$ git reset --hard <commit>
# 回到指定commit,並保留local尚未提交的修改
$ git reset --keep <commit>
# 取消已 add file
$ git reset HEAD <filename>
# 回到前一次 commit 的狀態
$ git revert HEAD
git config credential.helper store
git config --global --unset credential.helper
git config --system --unset credential.helper
$ git checkout <another-branch> <path-to-file> [<one-more-file> ...]
$ git status
$ git commit -m "'Merge' specific file from '<another-branch>'"
# Step 1.
$ git clone http://gitlab/zk/<project>.git
# Step 2.
$ git checkout development
# Step 3.
$ git pull
# Step 4.
Coding ...
# Step 5.
$ git add <file> or . {all file that was changed}
# Step 6. check the files you add
$ git status
# Step 7.
$ git commit -m "comment"
# Step 8.
$ git push origin development
# Step 9. git conflict happen
Resolve...
# Step 10. git conflict happen
$ git add <resolved-file>
# Step 11.
$ git push origin development
$ git checkout release
$ git merge development
$ git add .
$ git push
### forced update
$ git checkout release
$ git reset --hard development
$ git push --force origin release
# step1: change branch to master, and pull to update all commits
$ git checkout master
$ git pull
# step2: change branch to target, and pull to update commits
$ git checkout feature
$ git pull
# step3: merge master to feature(⚠️ current is feature branch)
$ git merge master
$ git checkout master
$ git pull origin master
$ git merge feature
$ git push origin master
git rm -r --cached .
git add .
git commit -m ".gitignore"
# create feature
git checkout -b desc-feature master
git status
git add <some-file>
git commit
# finish dev
git push -u origin desc-feature
git push
# merge master
git checkout master
git pull
#git pull origin desc-feature
git merge desc-feature
git push
git branch -d desc-feature
git submodule add <repository> [<path>]</path></repository>
Reference
이 문제에 관하여(Git 기본 튜토리얼), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/hyperredstart/git-tutorial-3o6b텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)