Notice
Recent Posts
Recent Comments
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Today
In Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

A Joyful AI Research Journey๐ŸŒณ๐Ÿ˜Š

Git, Mac) ์ปค๋ฐ‹ํ•œ ํ›„ ํŠน์ • Author, Committer์˜ ์ด๋ฆ„ ์ˆ˜์ •ํ•˜๊ธฐ ๋ณธ๋ฌธ

๐Ÿ’ปBootcamp Self-Study Revisionโœจ/Git, GitHub

Git, Mac) ์ปค๋ฐ‹ํ•œ ํ›„ ํŠน์ • Author, Committer์˜ ์ด๋ฆ„ ์ˆ˜์ •ํ•˜๊ธฐ

yjyuwisely 2023. 6. 10. 20:27

์ฒ˜์Œ์— ํ„ฐ๋ฏธ๋„์—์„œ ๊นƒํ—ˆ๋ธŒ ์•„์ด๋””, ๋น„๋ฐ€๋ฒˆํ˜ธ ์„ค์ •ํ•  ๋•Œ 
๊นƒํ—ˆ๋ธŒ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ ํด๋ž˜์‹ ํ† ํฐ(Tokens(Classic))์„ ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. 

1) ํด๋” ๊ฒฝ๋กœ๋ฅผ ์ง€์ •ํ•ด ์ฃผ๊ณ  

์˜ˆ์‹œ) cd /Users/yeongjinyu/Documents/github


2) git clone์„ ํ•œ๋‹ค.

์˜ˆ์‹œ) git clone https://github.com/yjyuwisely/Traveling-from-Ulju-gun.git

git clone ๊นƒ์ฃผ์†Œ



3) ํด๋” ๊ฒฝ๋กœ๋กœ ๋“ค์–ด๊ฐ„๋‹ค.
์˜ˆ์‹œ) cd /Users/yeongjinyu/Documents/github/Traveling-from-Ulju-gun



ํ„ฐ๋ฏธ๋„์—์„œ ๊นƒํ—ˆ๋ธŒ ์ปค๋ฐ‹ History์— ์žˆ๋Š” ์ž˜๋ชป ์ž…๋ ฅ๋œ
4) ํŠน์ • Author์˜ ์ด๋ฆ„์„ ์ž์‹ ์ด ์›ํ•˜๋Š” ๊นƒํ—ˆ๋ธŒ id๋กœ ์ˆ˜์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_NAME" = "์ž˜๋ชป ์ž…๋ ฅ๋œ Author's ID" ]
then
    GIT_COMMITTER_NAME="$์›ํ•˜๋Š” ID"
    GIT_COMMITTER_EMAIL="$์›ํ•˜๋Š” EMAIL"
    git commit-tree "$@"
else
    git commit-tree "$@"
fi' -- --branches --tags

git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_NAME" = "ย€ย export GIT_AUTHOR_EMAIL=@gmail.com”" ]
then
    GIT_COMMITTER_NAME="$yjyuwisely"
    GIT_COMMITTER_EMAIL="$yjyuwisely@gmail.com"
    git commit-tree "$@"
else
    git commit-tree "$@"
fi' -- --branches --tags


4.1) ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์œผ๋กœ, ๊นƒํ—ˆ๋ธŒ Commit ํžˆ์Šคํ† ๋ฆฌ์— ์žˆ๋Š” Copy the full SHA๋ฅผ ์ด์šฉํ•ด์„œ
์ฝ”๋“œ์— ์ž์‹ ์ด ์›ํ•˜๋Š” Committer, Author์˜ ID, EMAIL์„ ๊ฐ๊ฐ ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค.
๊ฒฐ๊ณผ๋กœ, ๊นƒํ—ˆ๋ธŒ History์—์„œ ํŠน์ • ID๊ฐ€ ์ปค๋ฐ‹ํ–ˆ๋‹ค๊ณ  ๋‚˜์˜จ๋‹ค.

git filter-branch --commit-filter '
if [ $GIT_COMMIT = ์ปค๋ฐ‹ ID ]
then
    export GIT_AUTHOR_NAME="$์›ํ•˜๋Š” ID"
    export GIT_AUTHOR_EMAIL="$์›ํ•˜๋Š” EMAIL"
    export GIT_COMMITTERS_NAME="$์›ํ•˜๋Š” ID"
    export GIT_COMMITTERS_EMAIL="$์›ํ•˜๋Š” EMAIL"
fi
git commit-tree "$@"
' -- --branches --tags

git filter-branch -f --commit-filter '
if [ $GIT_COMMIT = 0e9a567c2c04c2d0c09df51b88950034b54c1666 ] ||
[ $GIT_COMMIT = 03a9f0e18c491d838b820d6b7daadfee6b238506 ] ||
[ $GIT_COMMIT = e0bc86ef3fa54d363a3ac5b39ad7a3932c5aa327 ] ||
[ $GIT_COMMIT = 8cc73d934734d138498a2e17fc646323e230c51d ] ||
[ $GIT_COMMIT = f3d60c7e98781bbdea6eee7580882432da24c55f ] ||
[ $GIT_COMMIT = f2f685918250bfe4c2e1f5518f5559518457da05 ] 
then
    export GIT_AUTHOR_NAME="$yjyuwisely"
    export GIT_AUTHOR_EMAIL="$yjyuwisely@gmail.com"
    export GIT_COMMITTERS_NAME="$yjyuwisely"
    export GIT_COMMITTERS_EMAIL="$yjyuwisely@gmail.com"
fi
git commit-tree "$@"
' -- --branches --tags


git filter-branch -f --commit-filter '
if [ $GIT_COMMIT = ace20bb04315f0941473f012c2e286448f5b7300 ] 
then
    export GIT_AUTHOR_NAME="$yjyuwisely"
    export GIT_AUTHOR_EMAIL="$yjyuwisely@gmail.com"
    export GIT_COMMITTERS_NAME="$yjyuwisely"
    export GIT_COMMITTERS_EMAIL="$yjyuwisely@gmail.com"
fi
git commit-tree "$@"
' -- --branches --tags



4.2) ํ•˜๋‹จ์€ ๊นƒํ—ˆ๋ธŒ Commit ํžˆ์Šคํ† ๋ฆฌ์— ์žˆ๋Š” Copy the full SHA๋ฅผ ์ด์šฉํ•ด์„œ

Committer์˜ ์ด๋ฆ„, ์ด๋ฉ”์ผ์„ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.
* ์ฃผ์˜ํ•  ์ ์€ ์•„์ด๋””, ์ด๋ฉ”์ผ ์•ž์— $์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค.

git filter-branch --env-filter '
if [ $GIT_COMMIT = ์ปค๋ฐ‹ ID1 ] ||
   [ $GIT_COMMIT = ์ปค๋ฐ‹ ID2 ] ||
   [ $GIT_COMMIT = ์ปค๋ฐ‹ ID3 ]
then
    export GIT_COMMITTER_NAME="์›ํ•˜๋Š” ID"
    export GIT_COMMITTER_EMAIL="์›ํ•˜๋Š” EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

git filter-branch -f --env-filter '
if [ $GIT_COMMIT = c9487a021a930fe4e64a6425467fd5ac32fb219e ] ||
[ $GIT_COMMIT = 8f01743142ba72e3e15ec5d79d4804df66df2812 ] ||
[ $GIT_COMMIT = bac202c9abf2b30765a8b22928888ca0be29d3d7 ] ||
[ $GIT_COMMIT = 3810e5d9a5ed0464671ebaf62e9c2488a178598d ] ||
[ $GIT_COMMIT = b4ae165e784bad1df4d4a499597f57f73ebd0f6e ] ||
[ $GIT_COMMIT = dec4d0d04c37020add66733d1a2e9e7deca41242 ] ||
[ $GIT_COMMIT = bee2469629bf553ea023cd634a4037a3d9706d4b ] 
then
    export GIT_COMMITTER_NAME="yjyuwisely"
    export GIT_COMMITTER_EMAIL="yjyuwisely@gmail.com"
fi
' --tag-name-filter cat -- --branches --tags


git filter-branch -f --env-filter '
if [ $GIT_COMMIT = ace20bb04315f0941473f012c2e286448f5b7300 ] 
then
    export GIT_COMMITTER_NAME=“GR”
    export GIT_COMMITTER_EMAIL=“GR@gr.com”
fi
' --tag-name-filter cat -- --branches --tags


4.3) ํ•˜๋‹จ์€ Author์™€ Committer์˜ ์ด๋ฆ„์„ ์ผ์น˜์‹œํ‚ค๋Š” ์ฝ”๋“œ์ด๋‹ค.

git filter-branch --commit-filter '
if [ $GIT_COMMIT = ์ปค๋ฐ‹ ID1] ||
[ $GIT_COMMIT = ์ปค๋ฐ‹ ID2] ||
[ $GIT_COMMIT = ์ปค๋ฐ‹ ID3] ||
[ $GIT_COMMIT = ์ปค๋ฐ‹ ID4] ||
[ $GIT_COMMIT = ์ปค๋ฐ‹ ID5] ||
[ $GIT_COMMIT = ์ปค๋ฐ‹ ID6] ||
[ $GIT_COMMIT = ์ปค๋ฐ‹ ID7]
then
    export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
    export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
fi
git commit-tree "$@"
' --tag-name-filter cat -- --branches --tags

git filter-branch --commit-filter '
if [ $GIT_COMMIT = 0e9a567c2c04c2d0c09df51b88950034b54c1666 ] ||
[ $GIT_COMMIT = 03a9f0e18c491d838b820d6b7daadfee6b238506 ] ||
[ $GIT_COMMIT = e0bc86ef3fa54d363a3ac5b39ad7a3932c5aa327 ] ||
[ $GIT_COMMIT = 8cc73d934734d138498a2e17fc646323e230c51d ] ||
[ $GIT_COMMIT = f3d60c7e98781bbdea6eee7580882432da24c55f ] ||
[ $GIT_COMMIT = f2f685918250bfe4c2e1f5518f5559518457da05 ] 
then
    export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME"
    export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL"
fi
git commit-tree "$@"
' --tag-name-filter cat -- --branches --tags


git filter-branch --commit-filter '
if [ $GIT_COMMIT = 0d169a0c881586d95b8d9b367488fd054291964a ] ||
[ $GIT_COMMIT = 839ac762a6336bea854b4002529489446f41cae9 ] ||
[ $GIT_COMMIT = 4264efecfdb21af0eca6e0b2933acd44bb97caff ] ||
[ $GIT_COMMIT = ea68a9d2b51f8423b3f77cfbda466e9d0f9f6fd0 ] ||
[ $GIT_COMMIT = a8e63057e432df086989c9e474a672067dcdf861 ] ||
[ $GIT_COMMIT = a90046558c6c922c19b3978bb5b749c255163f45 ] ||
[ $GIT_COMMIT = 17acdb806d311df26bf06371f1a952b217f9f570 ] ||
[ $GIT_COMMIT = 9fcf391c4df3b3f005d7602513f07dd850864ca2 ] ||
[ $GIT_COMMIT = d57e6d04beec430205c575db394afe510365475a ] ||
[ $GIT_COMMIT = f2411507c7c43a854e78afb268dd33bd5703c9a2 ] ||
[ $GIT_COMMIT = 707aa5c25261aad307dfb1c0283e87dd095d088e ] ||
[ $GIT_COMMIT = fe573ca78cf31e2edc42e4769c9104bfd2df27b1 ]
then
    export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
    export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
fi
git commit-tree "$@"
' --tag-name-filter cat -- --branches --tags


5) ๋งˆ์ง€๋ง‰์œผ๋กœ, ํ•˜๋‹จ์˜ ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•œ๋‹ค. ์ž์‹ ์˜ branch ์ด๋ฆ„์œผ๋กœ ์ˆ˜์ •ํ•œ๋‹ค.

์˜ˆ์‹œ) git push --force origin master


In summary, --env-filter is used to modify the commit environment variables, while --commit-filter is used to modify the commit object itself.

Instead of modifying the commit history using git filter-branch, you can consider using other methods such as git rebase or git commit --amend to change the author information on individual commits. These methods allow you to modify the most recent commits without rewriting the entire history.

728x90
๋ฐ˜์‘ํ˜•
Comments