Git 리포지토리 필수 사항
8214 단어 repositorygit
이론
Git-repository는 git-branches 컬렉션입니다.
git-branch의 섹션/영역
모든 git-branch에는 기본적으로 5개의 섹션/드라이브/공간이 있습니다.
Working Area <-> Staging Area
Working Area Staging Area -> Stash Area -> Working Area
Staging Area <-> Commit Area
Commit Area <-> Remote Area
현실적인
메모:
git --help
를 사용하여 모든 git 명령을 참조하십시오.<file_path>
를 .
로 교체하여 모든 파일에 명령을 적용할 수 있습니다git-repository 생성 및 삭제
git init # create first branch (master-branch) in current folder and move all your files in working area
rm -rf .git # remove all git drive / sections
힘내 구성
두 가지 git 구성이 있습니다 - 글로벌(새 리포지토리의 기본값) 및 로컬(현재 리포지토리의 경우)
# use --global flag, to update gobal-configuation file
git config -l # list global and local git config
git config -e # update local git-config file which is present at ".git/config"
git config user.name "John Doe" # update User/Author name
git config user.email [email protected]
git config core.editor "code --wait" # set vs-code default editor for git
git config core.editor "nano -w" # set nano as default editor for git
업무 공간
git status # see which files / changes present in which area # file-names in red color are in working_area
# file-names in green color are in staging_area
git diff <file_path> # see changes present in working-area
git restore <file_path> # delete file-changes made working area
git clean -f # delete all files in working area
git clean -fd # delete all files and directories in working area
스테이징/인덱스 영역
git diff --staged # see changes in present in staging_area
git add <file_path> # move changes (newly created files or modification in previous files) to staging area
git restore --staged <file-path> # move changes from staging_area to working_area
은닉처
git stash # move all changes from working and staging area to stash_area
git stash list # list all blocks of temporariy changes
git stash pop # move most-recent block from stash_area to working_area ( position{0} )
git stash clear # delete all blocks in stash
커밋 영역
git commit -m '<message>' # move changes from staging_area to commit_area
# <message> is short text giving information about changes made in the commit
git commit --amend -m '<message>' # move from staging_area to commit_area, but replace last-commit instead of creating new-commit
git log # view all commits in current branch
git log --oneline # view all commits without description
git log --oneline --graph --all # view graphical representation of all branches
git diff <commit_id> # view changes present in commit_id
git revert <commit_ID> # remove all changes in given 'commit_ID'
git reset HEAD~1 # delete last commit and move changes from last-commit to working-area
# HEAD~2 will delete latest 2 commits, HEAD~3 will delete latest 3-commits and so on..
외딴 지역
git remote add <remote_area_name> <remote_area_url> # add connection to the remote_area
# you can give any name you want to remote_area_name, devlopers normally use "origin" for their first / default remote_area
git remote -v # list currently set remote_area / servers names and their areas
git remote remove <remote_area_name> # remove connection with remote repository
git push <remote_area_name> <branch-name> # copy changes in commit-area to remote_area
git fetch <remote_area_name> <branch_name> # copy branch remote_area to commit_area
git pull <remote_area_name> <branch_name> # merge remote branch to current branch
git clone <remote_area_url> # copy git repository from remote server/area to current folder
# for https-url
git config --global credential.helper cache # save github password so you don't have to type it again
git config --global --unset credential.helper # remove cached credentials
지점 관리
git branch <branch-name> # Create a new branch containing all git commits of current git-branch
git checkout --orphan <name> # create a fresh branch without commits from current-branch
git branch -d <branch-name> # delete branch
git branch -m <current-name> <new-name> # Change branch name
git checkout <branch-name> # move to another branch
git branch --all # list all local and remote branches
git merge <branch-name> # merge branch with <branch-name> to current branch
git merge <branch-name> --allow-unrelated-histories # merge branch whose git-history does not match with current branch, normally used to merge changes from another repository
git merge --abort # stop current merge process if there are conficts in merge, and you don't want to resolve them now
힘내 태그
git fetch --all --tags # fetch all tags from remote
git checkout tags/<version> -b <branch-name> # switch to a tag and create bracnh for it
Reference
이 문제에 관하여(Git 리포지토리 필수 사항), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/youngmahesh/git-repository-essentials-4fae텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)