Total Pageviews

2015/06/22

[egit] Fail to change branch from master to another

Problem
I want to change branch from master to another branch (i.e. WebcommUpload0618 )

But it failed to change branch via egit.
As I change branch again, but it show this error message:


The problem is there are some source belong to another branch but copy to master, because egit fail to do rollback. 

So it added some untracked files which belong to WebcommUpload0618 branch not master branch

Solution
1. use git status to list untracked files 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
albert@ALBERT-PC /D/git/dbm (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        dbm-service/src/main/java/gov/nta/dbm/repository/Dbm091fbRepository.java
        dbm-service/src/main/java/gov/nta/dbm/repository/impl/Dbm091fbRepositoryImpl.java
        dbm-service/src/main/java/gov/nta/dbm/service/Dbm016rService.java
        dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData1Vo.java
        dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData2Vo.java
        dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData3Vo.java
        dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData4Vo.java

nothing added to commit but untracked files present (use "git add" to track)

2. use git clean -n to list the files which will be removed
1
2
3
4
5
6
7
8
9
albert@ALBERT-PC /D/git/dbm (master)
$ git clean -n
Would remove dbm-service/src/main/java/gov/nta/dbm/repository/Dbm091fbRepository.java
Would remove dbm-service/src/main/java/gov/nta/dbm/repository/impl/Dbm091fbRepositoryImpl.java
Would remove dbm-service/src/main/java/gov/nta/dbm/service/Dbm016rService.java
Would remove dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData1Vo.java
Would remove dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData2Vo.java
Would remove dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData3Vo.java
Would remove dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData4Vo.java

3. use git clean -f to remove files
1
2
3
4
5
6
7
8
9
albert@ALBERT-PC /D/git/dbm (master)
$ git clean -f
Removing dbm-service/src/main/java/gov/nta/dbm/repository/Dbm091fbRepository.java
Removing dbm-service/src/main/java/gov/nta/dbm/repository/impl/Dbm091fbRepositoryImpl.java
Removing dbm-service/src/main/java/gov/nta/dbm/service/Dbm016rService.java
Removing dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData1Vo.java
Removing dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData2Vo.java
Removing dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData3Vo.java
Removing dbm-service/src/main/java/gov/nta/dbm/vo/Dbm016rData4Vo.java

After cleaning untracking files, then I can change granch succesfully

Reference
[1] https://ihower.tw/git/basic.html

No comments: