'GIT'에 해당되는 글 20건

  1. 2022.01.06 [GIT] branch/tag 운영 전략.
  2. 2020.06.18 [Spring] Spring Cloud Config 다중 Backend 사용 시...
  3. 2020.05.18 [Git] Master 브랜치로 돌리기.
  4. 2020.03.16 [Gitlab] HTTP Basic: Access denied 해결 하기
  5. 2019.03.19 [Git] git commit 통계 보기
  6. 2019.02.22 [개발일반] git log stats --all 사용
  7. 2018.07.24 [GIT] git submodule 삭제 하기
  8. 2018.01.12 [git] git log stats 보기
  9. 2017.10.27 [Git] Merge request 전 commit log 정리
  10. 2017.10.27 [Git] Commit log 수정하기

[GIT] branch/tag 운영 전략.

ITWeb/개발일반 2022. 1. 6. 12:12

브랜치로 운영 할 지 태그로 운영 할 지 결정해서 사용 하시면 됩니다.

태그의 경우는 수정이 안되기 때문에 배포 전략으로는 적합해 보입니다.

 

간단하게 branch/tag 운영 전략으로 Step 정리만 기록 합니다.

 

Step 1)

master 에서 dev 브랜치 생성

 

Step 2)

dev 브랜치로 dev, qa 환경까지 기능 테스트

 

Step 3)

qa 환경까지 검증이 완료 되었다면,

master 에서 merge 브랜치 생성

 

Step 4)

merge 브랜치에 dev 브랜치 머지

 

Step 5)

merge 브랜치를 qa에 배포

 

Step 6)

qa 배포 후 문제 없을 경우,

 

Step 7)

merge 브랜치를 master 로 머지

 

Step 8)

master 브랜치에서 release branch or tag 를 생성

 

Step 9)

release branch or tag 로 prod 배포

merge, dev 브랜치 삭제

 

브랜치 생성 및 삭제)

$ git checkout -b 브랜치명

$ git push origin 브랜치명

 

$ git branch -d 브랜치명

$ git push origin --delete 브랜치명

 

태그 생성 및 삭제)

$ git tag 태그명

$ git push origin 태그명

 

$ git tag -d 태그명

$ git push origin :태그명

 

 

:

[Spring] Spring Cloud Config 다중 Backend 사용 시...

ITWeb/개발일반 2020. 6. 18. 10:41

Spring Cloud Config 를 이용해서 다중 Backend 를 구성 할 수 있습니다.

그러나 order 옵션이 저는 제대로 동작 하지 않아서 실행 시 사용해야 하는 Backend 에 대한 profile 로 관리하기로 했습니다.

 

동시에 두 개의 Backend 를 사용 하는 것도 가능 한데 이게 같은 설정 파일이 양쪽에 다 존재 할 때 order 에 맞춰서 설정 정보를 가져 와야 하는데 이상하게도 git 에 있는 설정을 먼저 가져 와서 목적에 맞게 사용을 할 수 없었습니다.

 

spring:
  application:
    name: config-server
  profiles:
    active: awss3, git
  cloud:
    config:
      server:
        awss3:
          region: ap-northeast-2
          bucket: ${BUCKET-NAME}
          order: 1
        git:
          uri: https://git/config-repo.git
          skipSslValidation: true
          username: xxxxx
          password: xxxxx
          clone-on-start: true
          order: 2

저렇게 설정 하고 했었는데 잘 못된 부분이 있다면 댓글 좀 달아 주세요. :)

 

profile을 실행 시점에 awss3 나 git 으로 설정해서 사용 하도록 마무리 했습니다.

:

[Git] Master 브랜치로 돌리기.

ITWeb/개발일반 2020. 5. 18. 15:00

[로컬 Master 브랜치를 Remote Master 로 돌리기]

 

$ git fetch origin

$ git reset --hard origin/master

$ git clean -f -d

 

가끔 개발 브랜치 인줄 알고 merge 했는데, 헐... master 브랜치...

그럼 돌리세요. :)

:

[Gitlab] HTTP Basic: Access denied 해결 하기

ITWeb/개발일반 2020. 3. 16. 16:14

이 에러가 저장된 credential 정보가 틀려서 나는 것일 수도 있고 저 처럼 2FA 설정을 한 경우에 발생을 하는 경우도 있습니다.

 

Case 1) 저장된 Credentail 정보가 틀렸을 경우 아래와 같이 Reset 한번 합니다.

 

$ git config --system --unset credential

 

Case 2) 2FA 설정을 했을 경우 아래와 같이 access token을 생성 해서 Password 대신 사용을 합니다.

remote: HTTP Basic: Access denied
remote: You must use a personal access token with 'read_repository' or 'write_repository' scope for Git over HTTP.
remote: You can generate one at https://gitxxxxx.net/profile/personal_access_tokens

# 매번 입력하기 힘드니까 ID/PWD(Access Tokens) 를 저장해 둡니다.
$ git config --global credential.helper store

 

:

[Git] git commit 통계 보기

ITWeb/개발일반 2019. 3. 19. 11:27

파일명 마음에 안들지만 그냥 귀찮으니 그대로 올립니다.


$ tree -f

.

├── ./git-stats-period.sh

├── ./git-stats.sh

└── ./project_clone.sh


$ ./git-stats-period.sh 1 git-stats


git-stats-period.sh) 통계 추출 메인 스크립트

#!/bin/bash


PERIOD=$1

CLONE_DIR=$2


if [ "$#" -ne 2 ]

then

echo "example $ ./git-stats-period.sh PERIOD CLONE-DIR"

echo "example $ ./git-stats-period.sh 7 git-temp"

exit 0

fi


mkdir -p $CLONE_DIR


./project_clone.sh $CLONE_DIR


cd $CLONE_DIR

rm -f ./git-stats-temp.log

rm -f ./git-committers.log


for (( idx=1; idx<=$PERIOD; idx++ ))

do

# 디렉토리 목록을 가져오고, all.log 파일은 삭제

for dir in $(ls -d */)

do

echo ${dir%%/}

echo "rm -f ./${dir%%/}/git-stats-all.log"

echo "../git-stats.sh $idx ${dir%%/}"

rm -f ./${dir%%/}/git-stats-all.log

../git-stats.sh $idx ${dir%%/}

done

done


sort ./git-committers.log | uniq > ./git-uniq-committers.log



git-stats.sh) 통계 추출 실행 스크립트

#!/usr/bin/env bash


pwd

cd $2


#git stash

#git pull

#exit 0


DAYS_AGO=$1

DATE=`date -v -"$DAYS_AGO"d +%F`

PWD=`pwd`


rm -f ./git-stats-$DATE.log

echo "Date : $DATE" > "git-stats-$DATE.log"

echo "Date : $DATE" >> "git-stats-all.log"

echo "Date : $DATE" >> "../git-stats-temp.log"

# This script must exist under git repository.


echo "[Commit Statistics]" >> "git-stats-$DATE.log"

echo "[Commit Statistics]" >> "git-stats-all.log"

echo "[Commit Statistics]" >> "../git-stats-temp.log"

# total commit stats

USER_COUNT=`git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u | wc -l`

echo "Total Commit Users : $USER_COUNT" >> "git-stats-$DATE.log"

echo "Total Commit Users : $USER_COUNT" >> "git-stats-all.log"

echo "Total Commit Users : $USER_COUNT" >> "../git-stats-temp.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "git-stats-$DATE.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "git-stats-all.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "../git-stats-temp.log"

echo "" >> "git-stats-$DATE.log"

echo "" >> "git-stats-all.log"

echo "" >> "../git-stats-temp.log"


echo "[Committers]" >> "git-stats-$DATE.log"

echo "[Committers]" >> "git-stats-all.log"

echo "[Committers]" >> "../git-stats-temp.log"

# commit user list

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "git-stats-$DATE.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "git-stats-all.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "../git-committers.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "../git-stats-temp.log"

echo "" >> "git-stats-$DATE.log"

echo "" >> "git-stats-all.log"

echo "" >> "../git-stats-temp.log"


echo "[Commit Logs]" >> "git-stats-$DATE.log"

echo "[Commit Logs]" >> "git-stats-all.log"

echo "[Commit Logs]" >> "../git-stats-temp.log"

# each user commit stats

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "git-stats-$DATE.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "git-stats-all.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "../git-stats-temp.log"



project_clone.sh) git repo clone 스크립트

#!/bin/bash

CLONE_DIR=$1

echo "현재 받아 놓은 Repository는 모두 삭제 됩니다. 진행 하시겠습니까? (y/n)"
read answer

cd $CLONE_DIR

if [ "$answer" == "y" ]; then
  rm -rf *
else
  exit 0
fi

arr_repos=("GIT-REPOSITORY[http://...]")

for git_repo in "${arr_repos[@]}"; do
  if [ "$answer" == "y" ]; then
    git clone $git_repo
    echo ""
  fi
done



:

[개발일반] git log stats --all 사용

ITWeb/개발일반 2019. 2. 22. 16:32

귀차니즘....

recursive 하게 submodule 가져와서도 해야 하는데...

--submodule


#!/usr/bin/env bash


git stash

git pull


DAYS_AGO=$1

DATE=`date -v -"$DAYS_AGO"d +%F`

PWD=`pwd`


echo "Date : $DATE" > "git-stats-$DATE.log"

echo "Date : $DATE" >> "git-stats-all.log"

# This script must exist under git repository.


echo "[Commit Statistics]" >> "git-stats-$DATE.log"

echo "[Commit Statistics]" >> "git-stats-all.log"

# total commit stats

USER_COUNT=`git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u | wc -l`

echo "Total Commit Users : $USER_COUNT" >> "git-stats-$DATE.log"

echo "Total Commit Users : $USER_COUNT" >> "git-stats-all.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "git-stats-$DATE.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "git-stats-all.log"

echo "" >> "git-stats-$DATE.log"

echo "" >> "git-stats-all.log"


echo "[Committers]" >> "git-stats-$DATE.log"

echo "[Committers]" >> "git-stats-all.log"

# commit user list

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "git-stats-$DATE.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --format='%aN %ce' | sort -u >> "git-stats-all.log"

echo "" >> "git-stats-$DATE.log"

echo "" >> "git-stats-all.log"


echo "[Commit Logs]" >> "git-stats-$DATE.log"

echo "[Commit Logs]" >> "git-stats-all.log"

# each user commit stats

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "git-stats-$DATE.log"

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "git-stats-all.log"


:

[GIT] git submodule 삭제 하기

ITWeb/개발일반 2018. 7. 24. 07:44

이것도 복습 차원에서 정리해 봅니다.


Step 1)

  helloworld project root 로 이동 합니다.

  $ cd helloworld

 

Step 2)

  .gitmodules 를 열어서 삭제할 모듈을 지워 줍니다.

  helloworld$ vi .gitmodules

 

Step 3)

  삭제 하고자 하는 submodule 의 cache 를 삭제 합니다.

  helloworld$ git rm --cached hi-module

   

  아래와 같은 에러는 무시 하시거나 아래 명령 실행 후 위 명령어를 실행 합니다.

  $ git submodule deinit <path_to_submodule>

   

  fatal: Please stage your changes to .gitmodules or stash them to proceed

 

Step 4)

  .git 내 남아 있는 submodule 을 삭제 합니다.

  helloworld$ rm -rf .git/modules/hi-module

   

Step 5)

  해당 프로젝트에서 submodule 을 추가 한 것을 삭제 합니다.

  remove module (into intellij project)

   

Step 6)

  최종 submodule 을 삭제 합니다.

  helloworld$ rm -rf hi-module

   

Step 7)

  commit & push 합니다.

  helloworld$ git commit -m 'remove submodules'

  helloworld$ git push


:

[git] git log stats 보기

ITWeb/개발일반 2018. 1. 12. 15:45

그냥 제가 보고 싶은 형태로 구성하기 위해 스크립트 만들어 봤습니다.

참고문서)

https://git-scm.com/docs/git-log

https://git-scm.com/docs/pretty-formats


#!/usr/bin/env bash


DAYS_AGO=$1

DATE=`date -v -"$DAYS_AGO"d +%F`

PWD=`pwd`


echo "Date : $DATE" > "git-stats-$DATE.log"

# This script must exist under git repository.


echo "[Commit Statistics]" >> "git-stats-$DATE.log"

# total commit stats

USER_COUNT=`git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --format='%aN %ce' | sort -u | wc -l`

echo "Total Commit Users : $USER_COUNT" >> "git-stats-$DATE.log"

git log --shortstat --before="$DATE 23:59:59" --after="$DATE 00:00:00" | grep -E "fil(e|es) changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "lines inserted: ", inserted, "lines deleted: ", deleted }' >> "git-stats-$DATE.log"

echo "" >> "git-stats-$DATE.log"


echo "[Committers]" >> "git-stats-$DATE.log"

# commit user list

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --format='%aN %ce' | sort -u >> "git-stats-$DATE.log"

echo "" >> "git-stats-$DATE.log"


echo "[Commit Logs]" >> "git-stats-$DATE.log"

# each user commit stats

git log --before="$DATE 23:59:59" --after="$DATE 00:00:00" --all --pretty=format:'"%an", "%aD", "%s",' --shortstat --no-merges >> "git-stats-$DATE.log"


:

[Git] Merge request 전 commit log 정리

ITWeb/개발일반 2017. 10. 27. 17:19

master 브랜치를 가지고 있고 work 브랜치와 merge request 브랜치를 가지고 정리해 보겠습니다.


1. master 브랜치에서 work 브랜치를 하나 만듭니다.

2. work 브랜치에서 열심히 개발을 합니다.

3. master 브랜치에서 merge request 용 브랜치를 하나 만듭니다.

4. merge request checkout 상태에서 work 브랜치를 merge 합니다.

$ git merge WORK_BRANCH --squash

5. 특별히 conflict 난게 없으면 commit 합니다.

$ git commit -a -m 'simple commit message'

6. commit 이 잘 되었으면 push 합니다.

$ git push origin MERGE_REQ_BRANCH

7. 마지막으로 merge request 를 보내시면 됩니다.


:

[Git] Commit log 수정하기

ITWeb/개발일반 2017. 10. 27. 09:04

가끔 사용합니다.

# 먼저 git log 부터 확인 합니다.

$ git log


# head 부터 2개의 commit 로그를 보여 줍니다.

# 여기서 수정하고 싶은 log 에 pick 을 edit 로 수정 합니다.

$ git rebase -i HEAD~2


# 저장하고 나왔으면 아래 명령어를 차례로 실행 합니다.

$ git commit --amend

$ git commit --continue


# 이건 head commit log 를 바로 수정 할때 사용합니다.

$ git commit --amend


: