git-add

'git add --patch' to include new files?

我与影子孤独终老i 提交于 2020-01-22 04:11:33
问题 When I run git add -p , is there a way for git to select newly made files as hunks to select?? So if I make a new file called foo.java , then run git add -p, git will not let me choose that file's content to be added into the index. 回答1: To do this with every new files, you can run: git add -N . git add -p If you want to use it frequently, you can create an alias in your ~/.bashrc : alias gapan='git add --intent-to-add . && git add --patch' N.B : If you use this with an empty new file, git

What is the meaning of the “bang” or “!” before the git command?

老子叫甜甜 提交于 2020-01-13 07:54:46
问题 As you can see from this excerpt, there is a "!" before the git command. What's the point? [alias] commitx = !git add . && git commit - https://stackoverflow.com/a/8956546/1354543 I understand aliases and what the command itself is doing, but not the point of the "!" before the git command. 回答1: The ! means "run the following as commands to the shell", so in this case the alias git commitx expands to the equivalent of running git add . && git commit (which is a terrible terrible idea) 回答2: An

How to add symlinks to git repository on Windows?

风格不统一 提交于 2019-12-22 05:04:20
问题 I compile binaries for OS X using GitHub' s electron environment and want to add the output to a git repository. I tried git add . error: readlink("sulu.app/Contents/Frameworks/Electron Framework.framework/Electron Framework"): Function not implemented error: unable to index file sulu.app/Contents/Frameworks/Electron Framework.framework/Electron Framework fatal: adding files failed Any idea to work around this? 回答1: Windows command mklink /H "Link_File_Path" "Target_File_Path" Use above

`git add --patch` with `--word-diff`

让人想犯罪 __ 提交于 2019-12-21 07:58:06
问题 git add --patch provides a great interface for reviewing unstaged changes and then staging only the ones that are wanted in the next commit. Great, except for one thing: there is no obvious way to choose which diff view to use. In particular, I would like to be able to configure git add --patch to present diffs to me the same way that git diff --word-diff does. How can I achieve that? (N.B. neither --word-diff nor --word-diff --color is exactly the same as --color-words , and so this question

How to avoid specifying absolute file path while git-add

我们两清 提交于 2019-12-20 09:26:13
问题 Using git add command becomes tedious once the file path becomes lengthy. For e.g. git add src_test/com/abc/product/server/datasource/manager/aats/DSManger.java Is it possible to bypass specifying absolute file path? May be using some kind of pattern or something? I know that we can use git gui . But I want to do it using cmd line. Thanks in advance for the inputs. 回答1: For unix-like systems you can always use the star to point to files, e.g. git add *DSManager.java will include all DSManager

git add . vs git commit -a

走远了吗. 提交于 2019-12-17 23:29:08
问题 What's the difference between: git add . git commit -a Should I be doing both, or is that redundant? 回答1: git commit -a means almost[*] the same thing as git add -u && git commit . It's not the same as git add . as this would add untracked files that aren't being ignored, git add -u only stages changes (including deletions) to already tracked files. [*] There's a subtle difference if you're not at the root directory of your repository. git add -u stages updates to files in the current

Adding Only Untracked Files

蹲街弑〆低调 提交于 2019-12-17 17:18:47
问题 One of the commands I find incredibly useful in Git is git add -u to throw everything but untracked files into the index. Is there an inverse of that? In the last few months, I've often found myself in a position where I've interactively added some updates to the index and I want to add all of the untracked files to that index before I commit. Is there a way to add only the untracked files to the index without identifying them individually? I don't see anything obvious in the help docs, but

Fix GitLab error: “you are not allowed to push code to protected branches on this project”?

谁说我不能喝 提交于 2019-12-17 08:02:26
问题 I have a problem when I push my codes to git while I have developer access in my project, but everything is okay when I have master access. Where is the problem come from? And how to fix it? Error message: error: You are not allowed to push code to protected branches on this project. ... error: failed to push some refs to ... 回答1: there's no problem - everything works as expected. In GitLab some branches can be protected. By default only Maintainer/Owner users can commit to protected branches

Recover files that were added to the index but then removed by a git reset

元气小坏坏 提交于 2019-12-17 02:49:24
问题 I added some files to the index but then by mistake I deleted them with git reset --hard . How do I recover them? Here's what happened: I added all files using git add . I then committed When I checked the status, there were still files that weren't included in the commit from the add, which was strange I added the untracked files again and it worked this time But I wanted everything to be in 1 single commit so I looked up how to unstage what I just committed I used git reset --hard HEAD^ —

Unable to Git-add with force

不打扰是莪最后的温柔 提交于 2019-12-13 12:25:10
问题 I get git-status at ~/bin: # Untracked files: # (use "git add <file>..." to include in what will be committed) # # screen/dev/ I run git add --force screen/dev/ I get the same git-status as before. I add each file in the folder independently, but I get the same git-status. There is no .git in screen/dev/. The folder seems not to be a sumbodule. How can you add a folder and its content with force to my git at ~/bin? 回答1: You should not need ' --force ' or ' -f ' option: see git add: -f --force