Questions tagged [git-add]

git-add - Add file contents to the index

Before each commit in , you need to add file contents to the staging area.

The following will add all the files currently on the stage at the next commit:

$ git add .

This also adds the files recursively under the current working directory. Files previously tracked (i.e. they were in the last commit), still need to be added to the stage.

You can track new files specifically like so (where foo is the filename in this example):

$ git add foo

To add multiple files, separate them with a space like so (bacon and cheese being the other example files):

$ git add foo bacon cheese

References

330 questions
2
votes
1 answer

Difference between ( git add -A followed by git commit ) and git commit -a?

git add --all or git add -A followed by git commit -m "commit message" seem to produce a different result from git commit -am "commit message" when I thought they would produce the same final result. Am I doing something wrong with git commit -am…
haziz
  • 12,994
  • 16
  • 54
  • 75
2
votes
1 answer

Ignoring certain files in directory even when adding directory with -f

I just put my dotfiles in a repository in the manner suggested by Eli Barzilay here: So I’ve finally found a solution that takes the best of both: put the repo in a subdirectory, and instead of symlinks, add a configuration option for …
echristopherson
  • 6,974
  • 2
  • 21
  • 31
2
votes
2 answers

Finding next matching hunk when using git add --patch

I find the use of git add --patch very useful for my work-flow sometimes, like when I need to revise lots before anything is ready to commit, especially with documentation. If I have a large number of hunks to sift through, the search feature via /…
JFlo
  • 658
  • 6
  • 12
1
vote
2 answers

Simple Github commit not working (trying to add an image to my public image folder)

So i'm trying to do something i know is simple but its causing me some headaches. I am just trying to get an image from my app (im using MacFusion to ssh to our app vs having it on my machine locally). I basically dragged an image into the…
BennyB
  • 155
  • 4
  • 19
1
vote
2 answers

Although seemingly correct Syntax .gitignore File is ignored

I have written some powershell code, since I wanted to achive two things. The first one was to organize my gists and the second one to learn ps1 script syntax. Until now I guess I've managed some impressive things on one hand, on the other I got…
L00tz1ffer
  • 37
  • 6
1
vote
1 answer

Why is "git add" adding "C:/Program Files/Git/" in front of a given path starting with "/"?

While I am trying to do git add for a folder or for all files, I am getting the fatal error as shown below. MINGW64 /c/xampp/htdocs/d95x-dev (master) $ git add /vendor fatal: C:/Program Files/Git/vendor: 'C:/Program Files/Git/vendor' is outside…
1
vote
1 answer

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 --enable --global which I think essentially just adds these lines to my…
gchen
  • 126
  • 6
1
vote
1 answer

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 option. Is there any keyboard shortcuts or alternative methods…
muel
  • 43
  • 1
  • 13
1
vote
2 answers

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 that are modified add/rm only files that are…
eshirvana
  • 23,227
  • 3
  • 22
  • 38
1
vote
0 answers

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 repo as a simple commit of files, unless you delete…
1
vote
0 answers

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 on with a big file. def push_to_github(filename,…
Egidius
  • 971
  • 1
  • 10
  • 22
1
vote
0 answers

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 git commit -m "some commit message" I shouldn't have…
Asocia
  • 5,935
  • 2
  • 21
  • 46
1
vote
0 answers

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 work with it. Before we tracked those files…
1
vote
1 answer

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 with the three trees of Git, and that the index…
Eldrax
  • 499
  • 4
  • 12
1
vote
1 answer

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.txt for instance src/a/a1.txt, src/a/a2.txt…
CodeTalker
  • 1,683
  • 2
  • 21
  • 31