본문 바로가기

Git

git - bash로 한번에 push 하기

728x90

 

git add .
git commit -m "fix: 커밋메세지"
git push origin

 

혹은 새로운 브랜치라면 

 

git push --set-upstream origin 브랜치명

git add .
git commit -m "fix: 커밋메세지"
git push origin

 

 

위와 같이 일련의 명령어를 입력해야 한다.

bash 스크립트 만들어서 한방에 해결해보자

 


파일명이 bash.sh 이라고 가정한다.

 

[기존 브랜치에 푸시하는 경우]

sh ./bash.sh "fix: test 커밋입니다."
msg=$1 

git add .
git commit -m "$msg"
git push origin

 

 


[새로운 브랜치인 경우]

sh ./bash.sh "fix: test 커밋입니다."

 

branchName=$(git branch --show-current)
msg=$1

git push --set-upstream origin $branchName

git add .
git commit -m "$msg"
git push origin

 


 

다음은 

master 브랜치에서 작업을 한 뒤에

아래 4가지 일련의 과정을 한번에 처리하는

bash 스크립트를 해보자

 

1. 작업 내용 임시저장

2. 브랜치 생성 

3. 작업 내용 다시 불러오기

4. 작업한 파일 커밋 & 푸시하기