힘내 명령줄
Feb 19 2023
git 명령에 대한 모든 것 Version Control System 개발자가 함께 작업할 수 있도록 모든 버전의 기록을 동시에 유지 관리 VCS 유형 : CVCS : 중앙 집중식 버전 관리 시스템 DVCS : 분산 버전 관리 시스템 Git 수명 주기 Git Ubuntu 설치 sudo apt-get install git Windows 아래에서 다운로드 링크 git --version git stash 참조를 초기화합니다.
git 명령에 대한 모든 것
Version Control System
개발자가 동시에 작업할 수 있도록 모든 버전의 히스토리를 유지 관리
VCS 유형 :
CVCS : Centralized version control system
DVCS : Distributed version control system
힘내 수명주기
힘내 설치
우분투
- git 패키지는 apt를 통해 사용할 수 있습니다.
- apt-get을 사용하여 git 설치
sudo apt-get install git
윈도우
아래 링크에서 다운로드
- 설치 프로그램이 성공적으로 시작된 후 화면에 git 설정이 표시되어야 합니다 . 다음 및 마침 프롬프트에 따라 설치를 완료합니다.
git --version
초기화
- Git 초기화 명령은 새 버전 제어 프로젝트를 생성하거나 초기화하는 데 사용됩니다. Git에는 기존 서버 또는 관리자 권한이 필요하지 않습니다.
- 아래에 나열된 초기화에 대한 몇 가지 명령이 있습니다.
git init: 현재 디렉토리를 Git 저장소로 변환git clone: git clone은 기존 리포지토리의 복사본을 만드는 데 사용됩니다. 내부적으로 git clone은 먼저 git init를 호출하여 새 저장소를 만듭니다.git add: 파일이 스테이징 영역으로 이동
> `git add .` : all Files goes to staging area
> `git add file1.txt file2.txt` : specific Files goes to staging area
> `git add *.txt` : only extenction files staging area
> `git restore --staged FILE_NAME` : restore file from staging area
git push: 로컬 저장소에서 원격 저장소로 파일을 푸시합니다.git fetch: remote-repo에서 local-repo로 파일을 가져오는 데 사용됩니다.git pull : 2개의 명령 fetch 과merge> git init
> git add README.md
> git commit -m "commit"
> git branch -M main
> git remote add origin REPO_URL
> git push -u origin main
.gitconfig전역 Git 구성 파일은 사용자의 홈 디렉토리에 이름이 지정된 파일에 저장됩니다 . 운영 체제에 따라:- 특정 값을 저장하는 특정 명령이 있습니다.
> git config --global user.name ""
> git config --global user.email ""
> git config --global user.password ""
> git config --global core.editor "code --wait"
> git config --global -e
> git config --global credential.helper store : store the credentials
> git config --global --unset credential.helper : unset the credentials which are set
> git remote set-url origin https://[email protected]/USER_NAME/REPO_NAME.git
> git config --local user.name "UserName"
> git config --local user.email "email Address"
> git config --local user.password "personal Token"
> git config credential.helper store : store the credentials
> git config --local --unset credential.helper: unset the credentials which are set
> git commit -m "message"
> git commit --amend : Add Description or change commit message of the last previous commit
> git commit -am "message" : commit without stageing
> git reset --hard COMMIT_ID : delete old commit
> git reset --hard HEAD~COMMIT_NUMBER : delete old commit using HEAD pointer
> git reset --soft COMMIT_ID : delete old commit using HEAD pointer
> git show COMMIT_ID : show Actual Commit
> git revert Commit_ID : It will revert you code till Commit_ID
자식 숨김
- 커밋되지 않은 변경 사항을 나중에 사용하기 위해 저장하고 작업 복사본에서 되돌립니다.
git stash: repo의 변경 사항을 로컬에 숨김git stash pop: 현재 숨긴 변경 사항을 숨김
- git branch는 메인 리포지토리의 새 버전입니다.
- 우리가 대규모 프로젝트에 있고 클라이언트가 라이브 프로젝트에 영향을 주지 않고 기능을 업데이트하려는 경우 분기가 유용하다고 가정합니다.
- 작업을 마친 후 기본 리포지토리에 새 분기를 만들어야 하며 작업이 완료되면 기능 분기를 기본과 병합하여 업데이트가 기본 분기와 병합되도록 합니다.
> git branch Branch_Name : create new branch
> git checkout Branch_Name : change the branch
> git branch Old_Branch_Name New_Branch_Name : Rename branch
> git branch -D Branch_Name : Delete branch
> git log main..child : shows the unmarged commits
git merge Branch_Name: 부모와 마지 자식 분기
git merge --squash Branch_Name: 스쿼시로 마지(하위 분기 커밋 기록 제거 및 단일 커밋으로 마지)
- git rebase 명령을 사용하면 일련의 커밋을 쉽게 변경하여 리포지토리 기록을 수정할 수 있습니다. 커밋을 함께 재정렬, 편집 또는 스쿼시할 수 있습니다.
git rebase Branch_Name: Rebase를 이용한 마지(첫번째 가지의 베이스만 변경)
- git cherry-pick은 임의의 Git 커밋을 참조로 선택하고 현재 작동 중인 HEAD에 추가할 수 있는 강력한 명령입니다.
git cherry-pick COMMIT_ID_1 COMMIT_ID_2: 특정 커밋을 사용하여 마지

![연결된 목록이란 무엇입니까? [1 부]](https://post.nghiatu.com/assets/images/m/max/724/1*Xokk6XOjWyIGCBujkJsCzQ.jpeg)



































