git-add

Git add all subdirectories

依然范特西╮ 提交于 2019-11-29 21:17:37
I'm having trouble adding a folder and all of it's subdirectories to my git repository. I realized this is a very popular question after doing some googling and I've tried each suggestion with no luck, specifically the suggestion from the man page on git-add . I even tried git add -A with no success. For simplicity sake, say I initialized my git repository as Dir1 . Then I have the following directory structure of files. Dir1/file1-1.txt Dir1/file1-2.txt Dir1/Dir2/file2-1.txt Dir1/Dir2/Dir3/file3-1.txt My real files have subdirectories that span 5-6 levels deep, so is there a git command to

What's the difference between git add * and git add ., if any?

时光怂恿深爱的人放手 提交于 2019-11-29 17:31:09
问题 git animals had this series of commands: git init git add * git commit -a -m ‘initial commit and release!’ What does git add * do compared to git add . (which I normally do) are they the same? 回答1: git add * will add all the paths that are the result of the shell expansion of * whereas git add . will tell git to add the current directory. git add * won't add paths that begin with a . as the shell expansion of * considers these to be "hidden" paths. git add * will also fail if any expanded

Disable git add . command

别等时光非礼了梦想. 提交于 2019-11-29 15:42:30
Many times I mistakenly add unwanted files to the staging area using the git add . command. I wonder if there is a way I could completely disable this command, so that I only use git add file ? SVN re-education I guess it is a bad habit from svn, which has a default to add only tracked files [...] You must unlearn what you have learned :) You should run git status often. If files you want to ignore get listed as untracked files, you should then edit your .gitignore file, so that those files actually become ignored. Because git add doesn't affect ignored (and untracked) files, you will then be

Why is split option missing in git add -p?

醉酒当歌 提交于 2019-11-29 05:32:33
Trying to split a hunk into smaller ones by git add -p and split option, but entire file appears as one hunk and I can't split it. I can edit, but removing lines causes the patch to fail. git help add says I should have split, and I recall using it, but in my current example the option doesn't appear in the prompt. When I choose the option help is printed, which says I can choose s to split :-[ Git version: 1.9.1. Xubuntu 14, oh-my-zsh. The hunk is not one line, it's multiple lines. Any ideas why would that be? Edited with more data, here's console log: +last line of long text Stage this hunk

How to edit Git “add patch” hunks/diffs/lines during selective staging?

末鹿安然 提交于 2019-11-29 01:50:39
问题 I have a source file where 2 features have been added. In order to allow cherry-picking, I'd like to commit that in 2 phases: one for each feature. Until now, in similar situations, using git add -p served me well, to commit one feature while leaving the local files in their final stage. However, I now have the problem that git add -p wants to stage a hunk that includes edits for both features. Even though the edits are on separate lines, s (for "split") no longer wants to split up the hunk

'git add .' doesn't work

邮差的信 提交于 2019-11-29 00:28:41
I am currently trying to setup Git for a project I have been working on for a while. I do remember quite a while ago setting up Git but never used it for various reasons. Now I want to use it i am getting a strange issue that I believe is related to an old install. To start a fresh I installed a fresh Ubuntu OS so that there would be no Git install present and I copied the project (Grails) over. I then navigated to the directory and run the following commands: git init git remote add origin https://USERNAME@bitbucket.org/USERNAME/APPNAME.git Then I ran: git add . This is where i get the error

Is it possible to skip the staging area and (also) commit untracked, new files to git?

拥有回忆 提交于 2019-11-28 23:42:15
Is it possible to skip the staging area and (also) commit untracked, new files to git in a single built-in, command-line command ? If not, what are the alternatives ? http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository Providing the -a option to the git commit command makes Git automatically stage every file that is already tracked before doing the commit, letting you skip the git add part: $ git commit -a -m 'added new benchmarks' Thanks. Using a single, built-in, command-line command? No. Using two commands: git add -A git commit Using a custom alias: Add this to

git add . vs git commit -a

喜你入骨 提交于 2019-11-28 15:24:30
What's the difference between: git add . git commit -a Should I be doing both, or is that redundant? 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 directory and below, it's equivalent to git add -u . whereas git commit -a stages and commits changes to all

Staging Deleted files

岁酱吖の 提交于 2019-11-28 13:09:07
问题 Say I have a file in my git repository called foo . Suppose it has been deleted with rm (not git rm ). Then git status will show: Changes not staged for commit: deleted: foo How do I stage this individual file deletion? If I try: git add foo It says: 'foo' did not match any files. 回答1: Use git rm foo to stage the file for deletion. (This will also delete the file from the file system, if it hadn't been previously deleted. It can, of course, be restored from git, since it was previously

why it is not possible to git add .git/hooks/my-hook

余生颓废 提交于 2019-11-28 10:53:14
I would like to have some hooks always present in a clone of a given repository. Is there a way to add a file in .git/hooks in the repository? Thanks VonC It is possible to define your own hooks in a git template , but even there, those hooks would be non-executable ones. I.e. the user would still have to activate them (rename or activate the executable bit) once the repo is cloned. That way, said user won't have any unwanted script executed without his/her full knowledge and explicit approval. Doing otherwise would be too much of a security risk for anyone "blindly" cloning a repo . Sounds