프로그래밍

자주쓰는 github 명령어 정리

kugancity 2023. 2. 18. 14:26
반응형

 

 

 

 

자주 쓰는 github 명령어 정리

 

 

 

git config --global user.name ro****


git config --global user.email ****@****.com

# 저장소의 변경 사항 가져오기 + 자동 merge 
git pull 

# 변경된 파일 추가 
git add README.md


# 변경된 파일들 저장소로 commit 하기 
git commit -m "update README.md"
[master 4c07bfe] update README.md

1 file changed, 2 insertions(+), 2 deletions(-)



# git status 확인 git status
On branch master

Your branch is ahead of 'origin/master' by 1 commit.

  (use "git push" to publish your local commits)

nothing to commit, working directory clean



# commit 된 변경 사항들을 github 저장소로 push 한다. git push
Username for 'https://github.com': **

Counting objects: 7, done.

Delta compression using up to 12 threads.

Compressing objects: 100% (2/2), done.

Writing objects: 100% (3/3), 287 bytes | 0 bytes/s, done.


Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.

To https://github.com/

   5ef4664..4c07bfe  master -> master

 

#conflict 가 생겼을 경우 merge tool 사용하기 

git mergetool

 

 

예전 commit으로 돌리기 

특정 시점의 코드 버전이 필요한 것이면

git checkout commit번호 

 

현재 작업내용을 과거 이력으로 돌리려면

git revert commit번호 

 

 

git checkout is used to switch between different branches or to check out a specific commit or file from the repository's history. It is also used to create a new branch from an existing one. When you run git checkout, you are updating the files in your working directory to match the state of the specified commit or branch.

git revert is used to undo a commit by creating a new commit that undoes the changes made in a previous commit. It is a safe way to undo changes because it does not erase any commits or change the repository's history. When you run git revert, a new commit is created that undoes the changes made in the specified commit. In summary, git checkout is used to switch between branches or check out a specific commit or file, while git revert is used to undo changes made in a previous commit.

 

 

참고: http://www.devpools.kr/2017/01/31/%EA%B0%9C%EB%B0%9C%EB%B0%94%EB%B3%B4%EB%93%A4-1%ED%99%94-git-back-to-the-future/

728x90
반응형