git-add

Disable git add . command

我只是一个虾纸丫 提交于 2019-11-28 09:27:37
问题 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 ? 回答1: 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

Adding Only Untracked Files

☆樱花仙子☆ 提交于 2019-11-28 02:39:36
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 maybe I'm missing it? Thanks. Mat It's easy with git add -i . Type a (for "add untracked"), then * (for

Git add only all new files, not modified files [duplicate]

瘦欲@ 提交于 2019-11-27 20:44:32
This question already has an answer here: git: stage only new files 8 answers Is there a way to only add new files and not add modified files with git? That is, files that are listed as untracked with git status. Other than ofcourse adding each file separately. It's not absolutely necessary to do this in my case, the real question for me is answered here: How to make git-diff and git log ignore new and deleted files? That is, don't show diff on new files, so I'm asking this more because i couldn't find an answer to it anywhere. Maybe git add $(git ls-files -o --exclude-standard) git ls-files

'git add .' doesn't work

末鹿安然 提交于 2019-11-27 15:20:45
问题 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

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

流过昼夜 提交于 2019-11-27 15:00:39
问题 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. 回答1: Using a single, built-in,

Add all files to a commit except a single file?

泪湿孤枕 提交于 2019-11-27 09:55:49
I have a bunch of files in a changeset, but I want to specifically ignore a single modified file. Looks like this after git status : # modified: main/dontcheckmein.txt # deleted: main/plzcheckmein.c # deleted: main/plzcheckmein2.c ... Is there a way I can do git add but just ignore the one text file I don't want to touch? Something like: git add -u -except main/dontcheckmein.txt git add -u git reset -- main/dontcheckmein.txt Aquarius Power 1) To start ignoring changes to a single already versioned file git update-index --assume-unchanged "main/dontcheckmein.txt" and to undo that git update

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

青春壹個敷衍的年華 提交于 2019-11-27 05:57:22
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 ... Hcorg 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 (see permissions docs ). master branch is protected by default - it forces developers to issue merge

Git add only all new files, not modified files [duplicate]

寵の児 提交于 2019-11-27 04:28:04
问题 This question already has an answer here: git: stage only new files 8 answers Is there a way to only add new files and not add modified files with git? That is, files that are listed as untracked with git status. Other than ofcourse adding each file separately. It's not absolutely necessary to do this in my case, the real question for me is answered here: How to make git-diff and git log ignore new and deleted files? That is, don't show diff on new files, so I'm asking this more because i

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

谁说胖子不能爱 提交于 2019-11-27 03:52:11
问题 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 回答1: 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

How to stage a rename without subsequent edits in git?

一个人想着一个人 提交于 2019-11-27 02:14:49
问题 I have a file that I've renamed and then edited. I would like to tell Git to stage the rename, but not the content modifications. That is, I wish to stage the deletion of the old file name, and the addition of the old file contents with the new file name. So I have this: Changes not staged for commit: deleted: old-name.txt Untracked files: new-name.txt but want either this: Changes to be committed: new file: new-name.txt deleted: old-name.txt Changes not staged for commit: modified: new-name