How to track but not stage and how to unstage but not untrack?

后端 未结 2 984
长情又很酷
长情又很酷 2021-02-02 05:10

I have two concise questions:

  • How I can track files but without staging them ?
  • How I can unstage files for commit without untracking them ?

2条回答
  •  伪装坚强ぢ
    2021-02-02 06:08

    Track all of your files with git add. Commit all of the changes you want to commit and push to remote. Then stash your new file with git stash. Your file will be tracked but not committed. So in your example you would start by un-staging fileA. Then run git add README.md and git add composer.lock. git commit -m "Committing fun stuff.". Now we need to track the new file without staging it so we simply do git add fileA followed by git stash. When you're ready to commit fileA you can run git stash pop to commit/push to remote.

提交回复
热议问题