git bash 명령어
1.로그인
$ git config --global user.name "tmdwo706"
$ git config --global user.email ""
2.저장소등록
1)$git init
2)vi .gitignore
gitignore 샘플
# built application files *.apk *.ap_
# files for the dex VM *.dex
# Java class files *.class
# generated files bin/ gen/
# Local configuration file (sdk path, etc) local.properties
# Eclipse project files .classpath .project
# Proguard folder generated by Eclipse proguard/
# Intellij project files *.iml *.ipr *.iws .idea/
git push -f origin master
3.메세지와 동시에 커밋
$ git commit -a -m “First Commit”
$ git commit -am ‘First Commit’
//기존프로젝트 강압적으로 한번 올려야됨
4.원본 저장소에서 안겹치게 업데이트(fetch),덮어쓰기 pull
$git fetch origin
$git pull origin
5.git 저장소 두개이상 충돌시 .git 폴더 삭제->git init부터다시
7.add 취소
git reset
8.git commit 되돌리기
$ git reset --hard HEAD~1
$ git reset --soft HEAD~1
$ git reset --hard HEAD^
8.한글깨질때
Windows 버전에서 한글이 깨질 경우 입력어
$ git config --global core.quotepath false
9.commit 할 때 알아두면 좋을 몇 가지
● commit은 가능한 작은 단위로 자주 해두자.
● commit 메시지는 50자 이내로 간결하게 적용하며, 첫 글자는 대문자를 사용한다. (물론 영어로 작성시)
● 긴 내용이 필요할 경우에는 제목이후 한 줄을 비우고 내용을 작성한다.
● 메시지 마지막에는 마침표(.)를 넣지 않는다.
● 메시지 제목은 명령문 스타일의 간결한 문장을 사용한다.
예) Add file helloWorld.java, Remove deprecated methods, Refactor sub class for member
● 어떻게 보다는 무엇과 왜를 설명한다.
10. 각 올릴 폴더별로 git init 후 들어가서 각 remote 등록, 변하는 폴더들어가서 add-commit-push 과정만하면됨 , 등록은한번만
1. git add 명령을 하기 이전(stage에 올리지 않은 경우)
1.1 repository 내 모든 수정 되돌리기
$ cd {repository_root_dir}
$ git checkout .
1.2 특정 폴더 아래의 모든 수정 되돌리기
$ git checkout {dir}
1.3 특정 파일의 수정 되돌리기
$ git checkout {file_name}
2. git add 명령으로 stage에 올린 경우
$ git reset
3. git commit을 한 경우
3.1 commit 내용을 없애고 이전 상태로 원복
master 브랜치의 마지막 커밋을 가리키던 HEAD를 그 이전으로 이동시켜서 commit 내용을 없앰
$ git reset --hard HEAD^
3.2 commit은 취소하고 commit 했던 내용은 남기고 unstaged 상태로 만들기
$ git reset HEAD^
3.3 commit은 취소하고 commit 했던 내용은 남기고 staged 상태로 만들기
$ git reset --soft HEAD^
4. 모든 untracked 파일들을 지우기
git clean -fdx
5. git push를 한 경우 remote repository도 이전으로 되돌리기
$ git reset HEAD^ #local repository에서 commit을 하나 되돌림
$ git commit -m "..." #되돌린 것으로 commit
$ git push origin +master #remote repository를 강제로 revert
GIT REMOTE 저장소 변경
git 기존이력 삭제
1.ls -a 에서 나오는 ./git 폴더 삭제
2. git init
3.git remote -v 에서 원격저장소 주소 바꾸기
-git remote set-url origin 바꿀주소