sing Git and the Eclipse IDE, you have a series of commits in your branch history, but need to back up to an earlier version. The Git Reset feature is a powerful tool with just a whiff of danger, and is accessible with just a couple clicks in Eclipse.

In Eclipse, switch to the History view. In my example it shows a series of 3 changes, 3 separate committed versions of the Person file. After commit 6d5ef3e, the HEAD (shown), Index, and Working Directory all have the same version, Person 3.0.

 

 

Right-click on any of the commits to show the context menu, and select Reset to show a sub-menu with 3 options: Soft, Mixed and Hard. These options affect which of git's 3 sets of files are Reset.

 

 

Before proceeding, a brief reminder that Git has 3 different sets of the files.

First is the HEAD, which is everything that is safely committed into the Git repository.

 

Second is the Index, which are the files as they will look in the HEAD once you do the next commit - in Eclipse, the Git Staging view's “Staging Area” shows the files ready but not yet committed.

 

Third is the Working Directory. Think of this as the Sandbox in which you can work and actually make changes (the HEAD and Index are not editable files in the same way, they are stored in Git’s internal representation, not directly accessible for editing purposes).

 

The different shades of Reset affect one, two or all three of these sets.

So, in the History view above, everything is updated to version 3 of the Person file. How can we use Eclipse and Git to back up to Person version 2? Right-click on the version 2 commit and choose Reset.

 

Select “Soft (HEAD Only)” to revert to version 2 only in the HEAD file set. This leaves the Index and the Working Directory still on version 3. As a result, the History view changes to reflect the fact that the HEAD now points to Person version 2:

 

And, since the Index and Working Directory still have version 3, the Git Staging view shows that version in the Staged Changes, ready to work on some more in the Working Directory, or commit again.

 

A Mixed Reset affects both the HEAD and the Index versions of the file. Selecting this option alters the History view the same as the Soft Reset above, with the version 3 commit reverted and therefore disappearing. Since the HEAD and Index now have version 2 again, but the Working Directory was not affected by this reset, the file now reappears in the Git Staging view’s “Unstaged Changes” area.

 

A Hard Reset changes the file version in each of the three Git file sets: HEAD, Index and Working Directory. This effectively throws out an entire commit. It disappears from the History, and version 3 is replaced with version 2 in both the Index and the Working Directory as well. Since Eclipse EGit is about to change the Working Directory, it asks, “Are you sure?”

 

Selecting Yes will lose all changes that were made in version 3. They will be gone from the HEAD, the Index and the Working Directory.

 

The Hard Reset is the only time when Reset is dangerous. It is a powerful tool, but use with caution! The other scenarios above can be undone easily enough. But a Hard Reset overwrites the changes (almost) everywhere. If you know your way around the RefLog, you might be able to get it back, but then, why would you be reading this basic introduction to Git Reset?

 

Posted by 셋부터넷
,

출처 : lee-mandu.tistory.com/336

 

이클립스 git) 브랜치 생성,이동 및 병합

아무것도 모른 상태에서 시작한 git 배우기! 이제 이번 포스팅을 마지막으로 git에 대한 포스팅은 멈출 생각입니다. 이정도로 저 혼자 사용하기에는 제법 괜찮거든요. 그럼 이번시간에는 이클립��

lee-mandu.tistory.com

이클립스에서 branch를 생성하고, 이동 그리고 병합까지 해보겠습니다.

새로운 branch를 생성해보도록 하겠습니다.

프로젝트 우클릭  >  Team  >  Switch To  >  New Branch 를 눌러주세요.

 

Branch name을 정해줍니다.

git Bash를 이용할때보단 직관적이긴 합니다.

그리고 아래쪽에 보시면 'Checkout new branch' 에 체크되어있습니다.

 

확인을 누르시면 바로 새로운 branch에서 시작하게 됩니다.

만들고 나니 brach가 이동 된 것을 확인 할 수 있습니다.

 

그리고 새로운 내용을 기입하였습니다. 이제 commit을 해 보겠습니다.

프로젝트 우클릭  >  Team  >  Commit 을 선택합니다.

그러면 변동된 파일이 나타날 것이고 메시지를 입력하고 commit을 합니다.

git은 svn과 달리 꼭 메세지를 적어줘야 하더라고요..

 

그리고 이번엔 branch의 이동을 해보겠습니다. (다시 master로 이동하겠습니다.)

프로젝트 우클릭 > Team > Swich to에 보시면 이제 생성된 branch가 확인 되어집니다.

 

이제 변경된 내용들을 병합(merge)해 보겠습니다.

프로젝트 우클릭 > Team > merge 를 선택합니다.

그럼 branch 목록이 출력됩니다.

branch가 많다면 더욱 많은 목록이 출력될 것입니다.

 

저희는 이전에 변경한 new_eclipse branch를 선택하고 Merge해 보겠습니다.

그리고 master에서 변경된 파일로 가시면 merge된 모습을 확인 할 수 있습니다.

 

 

출처: https://lee-mandu.tistory.com/336 [개발/일상_Mr.lee]

 

 

 

'Source Manage > GIT' 카테고리의 다른 글

Eclipse에서 Git Commit 되돌리기  (0) 2020.10.12
Eclipse에서 원격 GIT에 프로젝트 공유하기  (0) 2020.10.12
GIT의 개념이해  (0) 2020.10.12
Posted by 셋부터넷
,

출처 : bool2.net/%EC%9D%B4%ED%81%B4%EB%A6%BD%EC%8A%A4%EC%97%90-egit-%EC%84%A4%EC%B9%98%ED%95%98%EA%B3%A0-%EC%A0%80%EC%9E%A5%EC%86%8C-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0/

 

이클립스에 Egit 설치하고 저장소 설정하기

Egit 설치 이클립스에서 Help>Install New Software를 클릭한다. Install 창이 뜨면 Add를 클릭하여 Name은 Egit, Location에는  입력한 후 OK를 클릭한다. 목록에서 Eclipse Git Team Provider를 선택> Next를 클릭> Next를 �

bool2.net

 

 

1. 프로젝트와 Git 연결

 1) 새 프로젝트를 생성하거나 기존 프로젝트를 불러온다.

 2) Navigator 창에서 프로젝트 선택 후 마우스 오른쪽 버튼을 클릭한다. Team> Share Project를 클릭한다.

 3) Configure Git Repository 창이 뜨면 Create를 클릭한다.

 4) Repository Directory를 지정하고 Finish를 클릭한다.

   

 5) Git Repository 창을 보면 추가된 프로젝트를 볼 수 있다.

 

 

2. Remote 저장소와 연결하기

 1) Git Repository 창에서 해당하는 프로젝트를 펼친다. Remote 항목 위에서 마우스 우클릭 후 Create Remote를 클릭한다.

 2) Remote 이름을 넣고 OK 클릭.

 

 3) Configure Push 창이 나오면 Change 버튼을 클릭한다.

 4) 이전에 만들어 둔 서버 URI를 입력한다. Protocol을 지정하고 User와 Password를 입력한 후 Finish 클릭.

 

 5) Configure Push 창이 다시 보인다. Save and Push를 클릭하면 현재 파일을 Remote에 올리게 되고 Save를 클릭하면 서버에 올리지 않고 Remote 정보만 저장한다. 현재는 로컬 저장소에 Commit하지 않았으므로 Save and Push를 클릭하면 에러가 발생한다. 먼저 로컬 저장소에 Commit하고 Remote에 Push할 수 있다. 따라서 여기에서는 Save를 클릭한다.

 

 

3. Commit – 로컬 저장소에 저장하기

 1) Commit을 하려면 저장하고 싶은 파일과 폴더를 선택하여 Git Staging 창의 Staged Changes에 끌어 넣는다. Commit Message도 작성해야 한다.

 

 2) Commit 목록에서 빼고 싶으면 해당파일에서 마우스 우클릭하여 Remove from Index를 클릭하면 Unstaged Changes로 이동한다. Unstaged Changes에서 Ignore를 하면 저장에서 제외된다. .gitignore 목록에 올라간다.

 

 3) Commit 버튼을 클릭한다. [NO-HEAD]가 master로 바뀌었다.

 

 

4. Push – 로컬 저장소에서 Remote로 소스 보내기

 1) Push Branch ‘master’를 클릭.

 

 2) Next 클릭.

 3) Finish 클릭.

 4) 이상이 없으면 다음 창이 뜬다. OK를 클릭하고 Remote에 올라갔는지 확인해 본다.

 5) Remote에 저장된 파일들이 보인다.

 

6. 작업 저장

 1) 이후에 변경된 파일을 올리려면 Team> Add to Index한다.

 2) Git Staging 창에 보면 Staged Changes에 변경된 파일이 보인다.

 3) Commit and Push를 하면 Local과 Remote 모두에 저장이 되고 Commit을 하면 Local에만 적용된다.

 

 

 

 

'Source Manage > GIT' 카테고리의 다른 글

Eclipse에서 Git Commit 되돌리기  (0) 2020.10.12
Eclipse에서 GIT Local 브랜치 생성/변경/병합  (0) 2020.10.12
GIT의 개념이해  (0) 2020.10.12
Posted by 셋부터넷
,