Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I discard changes for a file in Git Gui?

Tags:

git

git-gui

Often when using Git Gui I would like to reset/checkout a single file or just dismiss a hunk.

Is there a way to do this easily in Git Gui? If not, is there any particular reason that this feature is not available in Git Gui?

like image 417
Dirk Avatar asked Nov 27 '13 12:11

Dirk


People also ask

How do I remove changes to a specific file in git?

Try Git checkout --<file> to discard uncommitted changes to a file. Git reset --hard is for when you want to discard all uncommitted changes. Use Git reset --hard <commit id> to point the repo to a previous commit.

How do I remove files from git gui?

Step 1. Click on the Web IDE option on the commit information panel, this would ideally take you to the editor panel with the repo structure listed on the left blade. Step 2. Click on the directory you wish to delete and commit the new changes and merge with the other branches if required.


3 Answers

I had a same problem. Just found it out: CTRL+J or Commit - Revert Changes

like image 74
lienok Avatar answered Oct 04 '22 21:10

lienok


  1. Select the file from the file list in the left sidebar.
  2. In the Menu bar, under Commit, Click "Revert Changes" in the dropdown list.

Alternatively, you can use the keyboard shortcut Ctrl+J to trigger the same action on Windows.

enter image description here

like image 37
Siddarth Kanted Avatar answered Oct 04 '22 20:10

Siddarth Kanted


I know this way:

  1. The changes must be unstaged
  2. Go to Tools -> Add
  3. Choose whatever name you'd like for your command, then in Command write
    git checkout $REVISION -- $FILENAME
  4. Select (left-click) the file you want to checkout, without staging
  5. Choose from Tools the command you just created

The chosen file will be checked out to HEAD revision

like image 21
ThanksForAllTheFish Avatar answered Oct 04 '22 22:10

ThanksForAllTheFish