git-stage

Git adding “unchanged” files to the stage

左心房为你撑大大i 提交于 2019-12-08 17:02:37
问题 For a project I'm working on, I want to use: git add . -A to add some files to the stage. The problem is that Git thinks these files are unchanged from the last commit, so they are ignored. However, I personally changed the file, but Git still sees the file as unchanged. How can I "forcefully" add that single file to my repository? 回答1: check your .gitignore file there must be some pattern matching this file which is excluding file from being staged. Or you can use git add . -f to forcely add

Git invert staging area

℡╲_俬逩灬. 提交于 2019-12-05 18:16:20
问题 I have got changes in my staging area, and others not staged yet (some files have changes both in and out the staging area). I would like to invert the content of the staging area and the changes which are not staged. Does a shortcut exist in order to do that , without doing more complex actions like local side-branch commits, or diffs, or stashes [etc.]? Thanks. 回答1: Here’s how I do it: Commit the index to a temporary commit Commit the remainder to a secondary temporary commit Switch the

Differences between the staged and unstaged versions of the same file, using difftool [duplicate]

岁酱吖の 提交于 2019-12-04 18:09:54
问题 This question already has answers here : Show both staged & working tree in git diff? (3 answers) Closed 2 years ago . Is there a way of viewing the differences between the staged and unstaged versions of the same file? For example: Changes to be committed: modified: conf/application.conf Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: conf/application.conf This

Unstage all deleted files in Git

跟風遠走 提交于 2019-12-04 11:54:09
问题 I want to unstage all file deletes. Is there an easy way? I want to apply this to the file pattern of all deletes. 回答1: The output of git status --porcelain is a great way to build one-liners and scripts for tasks like this: git status --porcelain | awk '$1 == "D" {print $2}' | xargs git reset HEAD 回答2: In case your path-/filenames returned from git status contain space characters, the call to awk can be modified to include the entire (quoted) path/filename including spaces: git status -

Differences between the staged and unstaged versions of the same file, using difftool [duplicate]

依然范特西╮ 提交于 2019-12-03 11:45:56
This question already has answers here : Show both staged & working tree in git diff? (3 answers) Is there a way of viewing the differences between the staged and unstaged versions of the same file? For example: Changes to be committed: modified: conf/application.conf Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: conf/application.conf This happens when I stage a change and then I modify the file again, without staging it. EDIT The git status -vv command is not good

Git: need to recursively 'git rm' the contents of all bin and obj folders

浪子不回头ぞ 提交于 2019-12-03 11:42:37
问题 Someone by accident just commited all of their bin and obj folders to our repo (there are around 40 such folders). I would like to do a git rm -r on all of these folders. Is there a command to do this? 回答1: Have backups, find . -type d -name bin -exec git rm -r {} \; find . -type d -name obj -exec git rm -r {} \; Update With bash, you can set the shopt globstar, and be happy: shopt -s globstar git rm -r **/{obj,bin}/ Finally, if you need to remove these from the history of the repository,

Git: need to recursively 'git rm' the contents of all bin and obj folders

自作多情 提交于 2019-12-03 02:08:46
Someone by accident just commited all of their bin and obj folders to our repo (there are around 40 such folders). I would like to do a git rm -r on all of these folders. Is there a command to do this? Have backups, find . -type d -name bin -exec git rm -r {} \; find . -type d -name obj -exec git rm -r {} \; Update With bash, you can set the shopt globstar, and be happy: shopt -s globstar git rm -r **/{obj,bin}/ Finally, if you need to remove these from the history of the repository, look at git filter-branch and read the section on 'Removing Objects' from the Pro Git Book Once you revert

Why does checkout sometimes stage a file?

情到浓时终转凉″ 提交于 2019-12-01 09:24:59
When I first started using Git, I found the checkout command quite confusing. However, as I adapted to Git's model of version control, it started to make sense. Now I am having to teach Git to my coworkers, and I'm trying to explain checkout simply. I thought I had a simple explanation (from the documentation ): Checkout a branch or paths to the working tree That seems to unify some of the things you can do with checkout which seem like a diverse set of operations to someone new to Git: git checkout . git checkout HEAD . git checkout HEAD~2 git checkout feature/update-readme README.md ..

Getting Git-concept of “stage”

Deadly 提交于 2019-11-30 20:33:01
Still having a hard time getting my head wrapped around the concept of staging as it applies to Git. Can any analogies be made with SVN? What is the primary purpose of having a stage level in Git? Similarities: Files that should be part of the repository must be added in order to being tracked. Both tools use the add command to accomplish this. Adding files means to prepare a commit. Differences: Git allows some further kind of detail when adding files. You can decide to add a whole file or distinct lines of code. Adding files to the index or stage allows more flexibility. SVN automatically

Getting Git-concept of “stage”

我与影子孤独终老i 提交于 2019-11-30 04:25:53
问题 Still having a hard time getting my head wrapped around the concept of staging as it applies to Git. Can any analogies be made with SVN? What is the primary purpose of having a stage level in Git? 回答1: Similarities: Files that should be part of the repository must be added in order to being tracked. Both tools use the add command to accomplish this. Adding files means to prepare a commit. Differences: Git allows some further kind of detail when adding files. You can decide to add a whole file