Questions tagged [git-add]
git-add - Add file contents to the index
323
questions
1
vote
1
answer
30
views
git-add and git-diff use different diff tools?
TL;DR I configured a difftool and git-diff gives "intelligent" diffs but git-add creates "stupid" hunks. Why?
I configured the difftool to use nbdime with nbdime config-git --...
0
votes
1
answer
19
views
Commit separately specific files inside untracked new directory in git
I have a new created directory "supplier_directory", in which there are 3 new files. I need to add these files into different commits.
Commit N1 : file1 only
Commit N2 : file2 and file3
I'...
0
votes
0
answers
20
views
Why does git diff not show any difference after git add command? [duplicate]
When I add file changes by git add and then I do git diff, it does not show any difference. Is there any way to check file changes even after git add apart from git reset HEAD fileName.
0
votes
0
answers
48
views
Broken repos by applying git clone and add . to a parent folder
This is the 2nd time it happens to me. The first time I thought it was a hard drive problem.
I'm trying to back up all my projects, that don't have a Repos in it. Because of my bad practices, I've ...
0
votes
1
answer
56
views
git add giving a super long never ending output [duplicate]
So I am kinda new to git and github and wanted to push a project on github. However, when I add files
git add .
it gives a super long message that does not seem to end
warning: LF will be replaced by ...
-1
votes
1
answer
48
views
Cant pull nor commit from git for untracked file
I was trying to pull from a repo and it gives me that message but if I run git status it says that my working tree has diverged and if I try to add and commit it gives me that error, (btw those files ...
1
vote
1
answer
37
views
How can navigate one level back at the git interactive staging (add) command
After running the interactive staging git command $ git add -i and choosing one of the options for example "update", then I don't know how to get back to the root level to choose another ...
2
votes
1
answer
54
views
change color of "Stage this hunk" query in git bash
when doing git add -p in the git bash terminal, the query "stage this hunk" comes up in a very dark blue that is very difficult to see on the black background.
How can I change this to ...
1
vote
2
answers
114
views
git add/rm files based on the type of change (of the files)
Is there a way to stage or unstage (git add / git rm) files only based on what was the type of modification?
Like :
add/rm only files that are deleted
add/rm only files that are new
add/rm only files ...
3
votes
1
answer
125
views
`Git add --patch` multiple files: go to hunk from previous file
When running git add --patch, it presents a series of "hunks" that can be applied or skipped with y or n respectively, along with other options for editing/etc.
On occasion, when working ...
-1
votes
1
answer
113
views
Why do we need git add? Before git commit [duplicate]
Why do we need git add command?
I understand it starts tracking our file, puts it in staging area. But why do we really need it?
1
vote
0
answers
55
views
How do I tell git that I only want to add the current file content of a child repo, not the repo as a submodule
If you clone a git repo inside of another git repo (e.g. to install code for a library or plugin into the parent repo) it appears impossible to add the file content of that directory to the parent ...
0
votes
2
answers
306
views
what does git rm do as opposed to deleting by OS and git add
If we want to delete a file (say file1.txt) and stop the git repo to track it, it is said that we should use git rm file1.txt and then git commit -m "..." it. But deleting from the working ...
1
vote
0
answers
36
views
How to commit and push a database file of 60 or more Mbs using Python3.x to GitHub API?
I have been looking for a better way to automatically upload a new or existing file to my repository. The following code can only update an existing file (not a big deal for me now) and does not work ...
3
votes
1
answer
92
views
unable to add files with git add
I have tried to git add a file. But when I check git status, the file is still marked as "Changes not staged for commit".
I have read many similar questions and I have tried everything:
...
0
votes
2
answers
34
views
Command to tell git to not track certain files
I know there is a shortcut for this, and cannot remember it.
I am working in a repository, and have about 8 files I need to add and commit, and 2 that are modified, that I do not need to commit. ...
0
votes
1
answer
30
views
Files not being added to repository on Github-- repository appears empty
I added a new repository to Github. For some reason, my files didn't show up after following the command prompts. I checked Git to confirm that my website was in the repository and it shows that it is....
3
votes
2
answers
291
views
Why should someone use git add before git commit? OR why should someone use git add at all?
I am not an expert in git and I understand that the whole idea behind version control is to be able to record the history of the files. If we can keep track of changes made to files in the working ...
-1
votes
1
answer
509
views
the "git add <file_name>" command leads to the error "fatal: pathspec 'file_name' did not match any files
Before you mark as duplicate, I am referencing this similar question: Fatal: pathspec 'file.txt' did not match any files, GIT
However my issue seems slightly different from the one posted ...
0
votes
2
answers
296
views
Git stash partially staged file
Is there a way to stash partially staged files (created with git add -p) in a straightforward easy manner? I already know about git stash -p which behaves like add but with stashing, but I already ...
1
vote
0
answers
54
views
Is it possible to undo a `git add` and go to the exact same staging index as before?
I was trying to split my work into multiple commits. I have done this:
git add --patch my_file
# accepted, rejected, manually edited many hunks
# --->
# now my silly mistake comes
git add my_file
...
0
votes
0
answers
129
views
Git: How to track file from submodule folder in main repo?
I have a repository with a project, which contains several plugins. Plugins are added to the project as git submodules. Everything work okay, but the project may change some files in plugins while we ...
1
vote
1
answer
52
views
How does `git add` deal with changes like file<->directory?
This is a long question. I'm trying to reverse-engineer some basic Git functionalities, and am having some trouble wrapping my head around what git add really does under the hood. I'm already familiar ...
1
vote
1
answer
31
views
How to add all files to stage whose file path is given in a file
Let's say I have a file files_to_stage.txt having file paths like
src/a/a1.txt
src/a/a2.txt
src/b/b3.txt
src/b/b6.txt
src/c/c5.txt
Now I want to stage all files having paths present in files_to_stage....
0
votes
0
answers
56
views
git add only files that aren't tracked in master yet
Does git have a command for staging only files (of a specific extension) that aren't tracked by the main branch yet?
My specific use case is a GitHub action that triggers on PRs which compresses SVG ...
0
votes
3
answers
393
views
Undo .gitignore changes
I previously ignored a folder, but now I would like to ignore its content only: How do I remove/modify some entries from my .gitignore file so that git will track them again? I tried updating the ...
2
votes
1
answer
326
views
Can I mark a file for resolution without adding it to the index with one command?
When there's a conflict, git status shows this:
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
...
0
votes
1
answer
49
views
How merging works when we use git add <filename>?
Assume this is my project structure:
- project
- .git
- scr
- component
- file.js
I did clone the project
Made a new branch by git checkout -b "newBranch"
Made ...
2
votes
1
answer
716
views
WSL+samba+git: "error: insufficient permission for adding an object to repository database .git/objects" / git-clone / git-add permission errors
I'm working on Win10 using the WSL1 (Windows Linux Subsystem) with Ubuntu 20.04.1 LTS. I have a Samba (1.0) Network Share on which I want to create my git repository via my Ubuntu Terminal.
christian@...
-2
votes
1
answer
29
views
Set git globally add certain files of type [duplicate]
I want to setup git to stage only certain files of type.
With
git add *
in basic dir, i must stage only the files of type cpp,h,txt,html.
How i must do this?
-1
votes
2
answers
59
views
Why does 'Git add *' leave some files unstaged?
I initialized a new git repo in my Django project. All files( including the files in subdirectories and pipfile) are staged when I run git add * except the .__atomic-writegxd2tirf file. Why is this ...
2
votes
0
answers
85
views
How to refresh a chunk's diff, during `git add -p`
When staging files with git add in patch mode (-p) I sometimes find a mistake that I would like to correct, before keeping on with adding further changes.
Many possible options are prompted: confyrm, ...
4
votes
3
answers
3k
views
How do I see git added files?
Sometimes I run git add . and big files that weren't supposed to get added are added. How can I see which files were added without commiting? And how to 'un-add' those files or all files at once so I ...
-2
votes
1
answer
285
views
Can't add a file to git, seriously [closed]
Solved, as explained in a comment under the accepted answer.
I have been using Git since years and I am really surprised that I there is one specific file that I can't add to the staging area in one ...
0
votes
3
answers
419
views
What does git add do?
I initialized a folder with git init.
The size of contents in that is around 600MB. After doing git add, The size of .git became 600MB, So, It literally stores all the contents of my files? I thought ...
1
vote
1
answer
31
views
See the full git add patch
I use git add -p all the time. For large hunks I often go into (e)dit mode to review and adjust the hunk as desired.
Is there a way to edit the FULL diff (every hunk in every file), rather than make ...
0
votes
1
answer
180
views
"error: ... patch does not apply" when editing hunk with "git add -p"
tldr: why am I getting error: ... patch does not apply when editing a hunk and removing a line, even though it looks like it should work?
I'm editing a hunk while doing git add -p, where I want to ...
1
vote
1
answer
246
views
git add line by line and not by paragraph
Is there a way to add line by line in git.
I tried this:
git add -p
But this command is not performant for me. because I need to treat each line separately.
If there is no a solution, I'm ...
1
vote
1
answer
760
views
Git commit adds/removes files not staged for commit
I'm fairly new to using git and I've dug myself in to a hole a couple of times where one of my git commits ends up modifying files that do not show up when doing a git status. I'm curious if anyone ...
1
vote
1
answer
141
views
When rebasing, why doesn't git add --patch work?
In a git repository, I have a single file with a large commit I want to divide into multiple commits. I am trying to follow the instructions at this answer but I have run into a problem. git status ...
1
vote
1
answer
465
views
How do I "git add" a modified submodule into the main module?
I modified, added, committed and pushed a change to a submodule, then went up to the main module directory and ran:
# git status
...
Changes not staged for commit:
...
modified: deps/gr-d13 (...
1
vote
0
answers
210
views
git pre-commit hook: interaction between git add -p and git stash
I have written a git pre-commit hook which does the following:
Stash any changes that are not staged for commit
Run tests
Unstash changes
The purpose is to prevent false-positives or false-negatives ...
1
vote
0
answers
46
views
Git add is ignoring certain files even when .gitignore does not exist
I am facing a rather strange issue with my git working folders. Here's the summary:
I previously had a local git repo with a .gitignore file that ignored certain files/folders.
I deleted the repo (....
2
votes
1
answer
145
views
Stage changes in file below a certain line number [duplicate]
I made two sets of changes in a single file.
They are conceptually different so I would like to keep them in seperate commits.
Can I stage the changes in a certain range or everything above or a ...
2
votes
2
answers
316
views
Git merge file content outside of a repo (--no-index)
The git diff command (with the --no-index flag) works incredibly well to diff two files, irrespective of whether or not these two files are contained in a Git repo or not.
Example
$ git diff --no-...
0
votes
2
answers
426
views
Git add all modified files with some exceptions [duplicate]
With git I would like to add (almost) all the modified files, in practice those marked with the letter M in VScode, but I would like to add exceptions, that is, not to consider one or two files.
Is ...
4
votes
1
answer
695
views
How to get better hunks in git add interactive patch mode?
I often use git add -p somefile to interactively stage only parts of the in the given file. However, if the file has more complicated changes, the default diff goes awry and so do the hunks offered by ...
0
votes
1
answer
2k
views
Is there a difference between "git add ." and "git add *" with respect to outcome? [duplicate]
Both seem to add everything in the current directory. The Git add documentation points to pathspec, which points to fnmatch(3).
The docs suggests that git add . will add everything in the current ...
1
vote
1
answer
213
views
What does git add :/ actually do? [duplicate]
Since first learning Git a few months ago, I've been using git add :/ to stage my files before committing, with the impression that the command stages all modified and newly-added files in my Git ...
0
votes
1
answer
937
views
How to automatically resolve all conflicts in git rebase, "git add ."
The project I'm working on is a maven application with parent and child modules. Changes to the parent module go to the development branch. Each child module has its own branch that is rebased off ...