$ git init
: 깃 레포지토리를 생성하는 명령어
git init
을 실행하면 .git 디렉토리가 생성되어야 한다.
$ git status
: 깃 상태를 확인하는 명령어class FourCal:
def __init__(self,first,second):
self.first = first
self.second = second
def setdata(self,first,second):
self.first = first
self.second = second
def add(self):
result = self.first + self.second
return result
3. git status
다시 확인
아래와 같은 상태이다.
$ git add
$ git status
$ git commit -m "message"
$ git status
$ git log
class FourCal:
def __init__(self,first,second):
self.first = first
self.second = second
def setdata(self,first,second):
self.first = first
self.second = second
def add(self):
result = self.first + self.second
return result
def sub(self):
result = self.first - self.second
return result
git commit
에 -am
옵션 사용git log
git log
는 커밋 로그들을 보여준다.
class FourCal:
def __init__(self,first,second):
self.first = first
self.second = second
def setdata(self,first,second):
self.first = first
self.second = second
def add(self):
result = self.first + self.second
return result
def subtraction(self):
result = self.first - self.second
return result
$ git status
$ git diff
class FourCal:
def __init__(self,first,second):
self.first = first
self.second = second
def setdata(self,first,second):
self.first = first
self.second = second
def add(self):
result = self.first + self.second
return result
def subtraction(self):
result = self.first - self.second
return result
def mul(self):
result = self.first * self.second
return result
class MoreFourCal(FourCal):
def pow(self):
result = self.first == self.second
return result
$ git status
working tree, untracked file 차이
$ git add cal.py
$ git add cal2.py
$ git status
$ git commit -m "add mul method and cal2.py
$ git log
class MoreFourCal(FourCal):
def pow(self):
return self.first ** self.second
$ git status
class FourCal:
def __init__(self,first,second):
self.first = first
self.second = second
def setdata(self,first,second):
self.first = first
self.second = second
def add(self):
return self.first + self.second
def subtraction(self):
return self.first - self.second
def mul(self):
return self.first * self.second
-> $ git checkout -- cal.py
== $ git restore -- cal.py
-> $ cat cal.py
class MoreFourCal(FourCal):
def pow(self):
result = self.first ** self.second
return result
$ git add cal2.py
$ git status
$ git reset HEAD cal2.py
or $ git restore --staged cal2.py
$ git status
$ vim cal2.py
class MoreFourCal(FourCal):
def pow(self):
result = self.first ** self.second
return resul
def div(self):
if self.second == 0:
return 0
else:
return self.first/self.second
$ git commit -am "add div method"
git log
$ git reset HEAD^
리셋 뒤에 스테이징하지 않은 변경사항 = 커밋과 스테이징이 모두 취소되었음을 의미한다.
$ git log
print("1")
$ vim rev.py
$ git add rev.py
$ git commit -m "print1"
print("1")
print("2")
$ vim rev.py
$ git add rev.py
$ git commit -m "print2"
ecf8e1758dd93701cf9f4c66cf678929c538ed87
$ git reset --hard the commit hash or the print2
HEAD의 현재 위치는 ecf8e17입니다 print2 -> 최신 커밋이 되었다는 의미
$ git log
f2687d7affe4be2c10f6028f72ca19f82cc9394f
$ git revert the commit hash of print 5