简体   繁体   中英

Handling line endings for git

Here is what I messed up so far,

  1. I copied (not cloned) a rails project from windows to linux pc

  2. Then created a new branch and made lots of changes

  3. At last commited twice whole project and pushed it to a remote repository with windows line endings.

Problem: so my problem is that, since I copied the project from windows to linux, when I run git status whole project shows modified. I don't see the changes I made specifically. Since I committed and pushed whole project, I lost history of files change.

What is needed: So I want to remove my last two commit but I want to keep my changes that I made. Then I want to convert the line endings from windows to unix of whole project so that when I run git status I see only the files that I changed, not whole project. And then I want to commit and push to remote.

It would be nice if there is a solution for this mess.

I am not sure if this will be helpful, I am working on a rails project and my IDE is rubymine.

To undo your last two commits run this:

  1. git reset --soft HEAD~2 . This will put the files involved in the commits into your working directory.
  2. Run git status and they will show as staged changes (ready for commit).
  3. Edit your files.
  4. Stage and commit your changes. Important: Don't push
  5. Run git pull .
  6. Run git push

Make sure you commit your changes and do a git pull prior to git push , otherwise your attempt to push will cause conflict and will be rejected.

You can use git filter-branch . Similar question here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM