GitHub - Android Studio

jkweyu·2024년 11월 17일
0

GitHub

목록 보기
1/10
post-thumbnail

androidstudio개발 툴에서 git과 원격레포지토리(GitHub)를 이용한 예제

1.안드로이드 프로젝트 생성

2. 안드로이드 프로젝트에 git 레포지토리 생성

기존 터미널을 이용한 git init 명령어 기능을 안드로이드 스튜디오 프로그램에서 수행

안드로이드 스튜디오 상단 메뉴에서 VCS -> Create Git Repository를 클릭

클릭후 VCS메뉴는 Git메뉴로 변결

3. GitHub 레포지토리 생성 및 주소확인

GitHub 레포지토리 생성

GitHub 레포지토리 주소

4. 안드로이드 프로젝트와 원격레포지토리(GitHub) 추가

기존 터미널을 이용한 git remote add origin 레포지토리주소 명령어 기능을 안드로이드 스튜디오 프로그램에서 수행
Git 메뉴 -> Manage Remotes

+ 버튼클릭후 GitHub 레포지토리 주소 추가

4. androidstudio에서 파일 수정 및 커밋 생성

안드로이드 스튜디오의 터미널 이용

안드로이드 스튜디오의 GUI 이용

5. 커밋된 변경 사항을 원격레포지토리에 푸시

기존 터미널을 이용한 git push origin master 명령어 기능을 안드로이드 스튜디오 프로그램에서 수행
안드로이드 스튜디오

깃허브

6. 브랜치 확인

git branch로 현재 브랜치 확인

➜  PracticeGit git:(master)git branch

6. 브랜치 생성

git branch 브랜치명으로 브랜치 생성

➜  PracticeGit git:(master)git branch testBranch

7. 브랜치 변경(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 생성 확인

8. master브랜치로 전환 후 병합

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] 충돌 수정

9. 원격레포지토리에 푸시

충돌 수정후 커밋한 내용을 원격레포지토리(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

깃허브

0개의 댓글