androidstudio개발 툴에서 git과 원격레포지토리(GitHub)를 이용한 예제
기존 터미널을 이용한 git init
명령어 기능을 안드로이드 스튜디오 프로그램에서 수행
안드로이드 스튜디오 상단 메뉴에서 VCS -> Create Git Repository를 클릭
클릭후 VCS메뉴는 Git메뉴로 변결
GitHub 레포지토리 생성
GitHub 레포지토리 주소
기존 터미널을 이용한 git remote add origin 레포지토리주소
명령어 기능을 안드로이드 스튜디오 프로그램에서 수행
Git 메뉴 -> Manage Remotes
+ 버튼클릭후 GitHub 레포지토리 주소 추가
안드로이드 스튜디오의 터미널 이용
안드로이드 스튜디오의 GUI 이용
기존 터미널을 이용한 git push origin master
명령어 기능을 안드로이드 스튜디오 프로그램에서 수행
안드로이드 스튜디오
깃허브
git branch
로 현재 브랜치 확인
➜ PracticeGit git:(master) ✗ git branch
git branch 브랜치명
으로 브랜치 생성
➜ PracticeGit git:(master) ✗ git branch testBranch
testBranch로 전환
git checkout testBranch
명령어로 브랜치 전환
➜ PracticeGit git:(master) ✗ git checkout testBranch
'testBranch' 브랜치로 전환합니다
testBranch의 main클래스 작업
class main {
//안드로이드 스튜디오의 GUI를 이용한 커밋
//testBranch에서 생성한 코드
var testString = "testBranch"
}
testBranch에서 커밋
git commit -m "working on testBranch"
명령어 입력후 git log
로 커밋 확인
commit ce44db5ab8c00e2d3cdcbb3d5300b28fb4c4c04a (HEAD -> testBranch)
Author: Liminghing <im349412@gmail.com>
Date: Sun Nov 17 17:26:18 2024 +0900
working on testBranch
testBranch을 깃허브에 푸시
git push origin testBranch
명령어
➜ PracticeGit git:(testBranch) ✗ git push origin testBranch
오브젝트 나열하는 중: 19, 완료.
오브젝트 개수 세는 중: 100% (19/19), 완료.
Delta compression using up to 10 threads
오브젝트 압축하는 중: 100% (2/2), 완료.
오브젝트 쓰는 중: 100% (10/10), 699 bytes | 699.00 KiB/s, 완료.
Total 10 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote:
remote: Create a pull request for 'testBranch' on GitHub by visiting:
remote: https://github.com/Liminghing/Practice-Git-Project/pull/new/testBranch
remote:
To https://github.com/Liminghing/Practice-Git-Project.git
* [new branch] testBranch -> testBranch
깃허브에 testBranch 생성 확인
master브랜치로 이동
git checkout master
명령어로 master브랜치로 이동
➜ PracticeGit git:(testBranch) ✗ git checkout master
'master' 브랜치로 전환합니다
testBranch 병합
git merge testBranch
명령어로 testBranch 병합
➜ PracticeGit git:(master) ✗ git merge testBranch
자동 병합: app/src/main/java/com/example/practicegit/main.kt
충돌 (내용): app/src/main/java/com/example/practicegit/main.kt에 병합 충돌
자동 병합이 실패했습니다. 충돌을 바로잡고 결과물을 커밋하십시오.
충돌 수정
git merge testBranch
과정에서 발생한 충돌 수정
충돌 수정후 커밋
➜ PracticeGit git:(master) ✗ git add app/src/main/java/com/example/practicegit/main.kt
➜ PracticeGit git:(master) ✗ git commit -m "충돌 수정"
[master eb3c32e] 충돌 수정
충돌 수정후 커밋한 내용을 원격레포지토리(GitHub)에 푸시
➜ PracticeGit git:(master) ✗ git push origin master
오브젝트 나열하는 중: 48, 완료.
오브젝트 개수 세는 중: 100% (48/48), 완료.
Delta compression using up to 10 threads
오브젝트 압축하는 중: 100% (6/6), 완료.
오브젝트 쓰는 중: 100% (30/30), 1.69 KiB | 1.69 MiB/s, 완료.
Total 30 (delta 3), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (3/3), completed with 1 local object.
To https://github.com/Liminghing/Practice-Git-Project.git
6636090..eb3c32e master -> master
깃허브