3주차 미션 목표
- 클래스(객체)를 분리하는 연습
- 도메인 로직에 대한 단위 테스트를 작성하는 연습
공통 피드백에서 반영한 부분
- 함수(메서드) 라인에 대한 기준 - 15라인(3주차 피드백)
- 성공하는 케이스 뿐만 아니라 예외에 대한 케이스도 테스트한다(3주차 피드백)
- 연관성이 있는 상수는 static final 대신 enum을 활용한다(3주차 피드백)
우아한테크코스 프리코스 미션들을 복습하고 있었다.
그러던 와중에, 해당 미션들을 저장하는 branch를 실수로 main
에 저장하고 있었다.
그래서 이전에 만든 repository 기존 branch을 새로운 repository(저장소)를 만들어서 새 branch에 가져오기(복사하기)로 했다.
즉, old repository의 branch -> new repository의 branch로 복사하는 것이다.
(기존 branch main
-> 새 branchfancy-log2
으로 복사하기)
기존 repository명을 old-java-bridge-review
이고, branch명은 main
이다.
새로운 repository명을 new-java-bridge-review
이고, 새 branch명은 fancy-log2
이다.
나는 내 기존 repository에 있는 branch를 가져오는 걸로 했다. (상대방 repository에서 가져오는 방식도 같다)
나는 IntelliJ에서 제공하는 terminal에서 작업했다.
기존 branch를 복사하기 위해서는 새 branch(fancy-log2)에서 작업해야 한다.
따라서, 새 branch인 fancy-log2
를 먼저 추가해준다.
상대방(혹은 나)의 repository에 있는 기존 branch를 저장하는 새 branch를 추가한다.
나는new-java-bridge-review
repository에서 새 branch명 fancy-log2
를 만든다.
git checkout -b [새 브랜치명]
위의 코드를 해석하면,
새로운 branch를 만들고 나서 동시에 새로운 branch에 이동이 된다는 의미다.
깃 레포지토리 링크
-> 리모트명
에 저장
git remote add <리모트명> <깃 레포지토리 링크>
git remote add fancy-log2-remote http://github.com/fancy-log/old-java-bridge-review.git
Git
을 클릭하면 위와 같이 remote명 fancy-log2-remote
가 추가된 것을 볼 수 있다.git pull <remote명> <remote의 branch명>
위의 코드를 해석하면,
2번에서 git repository 링크를 저장한
리모트명에 있는 branch(main)를 new-java-bridge-review
repository의 branch fancy-log2
에 저장한다는 의미이다.
그러면 기존 repository 있던 branch(main) 안에 있는 코드와 히스토리가 새 repository branch(fancy-log2)에 복사된다.
[추가 설명]
git pull 을 해주면 현재 사용하고 있는 branch(fancy-log2) 에 remote 되어 있는 특정 branch를 pull 해오게 된다.
Git
을 클릭하고 해당 branch fancy-log2
를 클릭하면 커밋 내용과 코드가 복사되었다는 것을 확인할 수 있다.GitHub 계정과 commit 이메일 계정이 동일하거나
commit이 Fork한 repository가 아닌 나만의 repository에서 이루어져야 한다
[1] 일단 내 git hub에 새로운 레파지토리를 만든다.
[2] terminal을 연다.
[3] 복사하고자 하는 repository를 bare clone한다.
$ git clone –bare https://github.com/exampleuser/old-repository.git
[4] 새로운 레파지토리로 Mirror-push
$ cd old-repository.git
$ git push –mirror https://github.com/exampleuser/new-repository.git
[5] 처음에 임시로 생성했던 local repository를 삭제
$ cd ..
$ rm -rf old-repository.git
fork 해온 repository 잔디 심는 방법 : repository 복사해오기 duplicate the repository
Set : 중복을 허용하지 않은 자료구조이다.
리스트를 Set으로 변환해서 크기를 비교한다.
크기가 달라졌으면 리스트에 중복된 요소가 있었다는 것을 의미한다.
@DisplayName("중복인지 확인")
@Test
void DuplicateTest() {
List<Integer> userDuplicate = Arrays.asList(1,1,2,3,4,5);
// Set 으로 변환
Set<Integer> userNoDuplicate = new HashSet<>(userDuplicate);
if(userNoDuplicate.size() != userDuplicate.size()) {
System.out.println("중복된 요소가 있습니다.");
System.out.println("전체 개수는 " + userDuplicate.size()); // 6개
System.out.println("중복되지 않은 개수는 " + userNoDuplicate.size()); // 5개
}
}