Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit and file with many chunk #4

Closed
papaDoc opened this issue Jul 28, 2016 · 1 comment
Closed

Commit and file with many chunk #4

papaDoc opened this issue Jul 28, 2016 · 1 comment

Comments

@papaDoc
Copy link

papaDoc commented Jul 28, 2016

Hi,

I was wondering what happen when you commit only some chunk of a file. (Maybe you want the remaining chunk to be added in another commit later on).

The git add at the end of the script will add the complete file. Rhe whitespace modification and also the chunks that were left for the "next" commit.

@imoldman
Copy link
Owner

imoldman commented Sep 6, 2016

Actually, it supports partial commit, In script, the codes say,

  # since $file in working directory isn't always equal to $file in index, so we backup it
  mv -f "$file" "${file}.save"

It means it will backup the files in working tree, and then,

 # discard changes in working directory
  git checkout -- "$file"

As comments say, It discards the modifications in files in working tree. Now, the file in working tree is equal to the one in index. In other words, the files in working tree only contain the modification that user want to commit.

So it's friendly to partial commit. Thank U!

@imoldman imoldman closed this as completed Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants