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
1
vote
2 answers

How do I commit only "git add -p file" changes without other changes to same file and without staged renamings?

The problem is that I cannot apparently make a partial commit of four lines' worth of changes in a file, out of about all 200 or so changed lines in that file. It might be due to the command I mistakenly did and then supposedly corrected. I am an…
cardiff space man
  • 1,442
  • 14
  • 31
1
vote
2 answers

git move part of changes from "to be comitted" to local changes

I have a file that I modified with 2 set of changes: formatting and adding new feature. I need to turn them into 2 commits. - Formatting changes - New Feature A. Now I used git add --patch and staged all the formatting stuff. So I have: Changes…
Mazeryt
  • 855
  • 1
  • 18
  • 37
1
vote
1 answer

Read only permission for file on git

I am trying to give permission 400 to a file on git and try to commit the same. But is trying to commit with permssions as " create mode 100644 " Is it possible to commit file with 400 permissions in git or should I git clone and handle permission…
Zaks
  • 668
  • 1
  • 8
  • 30
1
vote
3 answers

Trying to git add -p but git does nothing

I'm trying to use this in order to apply a big change I've worked on. I did the following: 1. git pull (before I started working) 2. changed some code 3. git diff > ~/my_diff 4. git stash 5. git pull 6. git stash pop This failed due to…
CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
1
vote
1 answer

Why doesn't git add --patch work with git add -N of a binary file?

git add --patch doesn't work with binary files added with git add -N. Does anyone know why? In the following example you can see that git add --patch picks up the text file a but not the binary file 0. echo a > a echo '\0' > 0 git add -N 0 git add…
Tom Ellis
  • 9,224
  • 1
  • 29
  • 54
1
vote
2 answers

How to git stage an one by one the folder with files in Visual Studio Code?

I have a folder with other subfolders. Then in each subfolder many files (over 1000). I want to stage, commit each subfolder at a time (not all subfolders folders at once). Do I have in VSCode a way to do this easly form interface? Because I do not…
radu c
  • 4,138
  • 7
  • 30
  • 45
1
vote
1 answer

Difference between git add ., git add -A and git add -u

What is the difference between the following commands? git add . git add -A git add -u I tried to execute them, and they create the same results.
Marek
  • 3,935
  • 10
  • 46
  • 70
1
vote
1 answer

Changes not staging during Python subprocess call of empty commit

At the end of a Python program I have: subprocess.call(["git", "add", "."], shell=True) subprocess.call(["git", "commit", "-m", "'{}'".format("commit message"), "--allow-empty"], shell=True) This commit has no changes from the previous commit…
BigMike
  • 11
  • 2
1
vote
4 answers

time of last git-add

Note, please be kindly to read my question first, befroe mark it as duplicate of how-can-you-undo-the-last-git-add. Is there a git native way to get when the last git add . executed? I recent do some coding in my ios project, and execute git add .…
LF00
  • 27,015
  • 29
  • 156
  • 295
1
vote
4 answers

How to avoid to add the target folder into a GIT commit?

I am not so into GIT and I have a doubt. I have a project that is composed by these folders and file: $ ls bin/ lock.lck pom.xml src/ target/ I know that doing: git add . I am adding all the files in my staging area, so if then I commit and…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
1
vote
1 answer

Git submodules : must a file located in a submodule's folder be tracked by that same submodule?

I have git repo A containing submodule B. Some file file.c is located inside B's folder, itself inside of A's folder as you'd expect. Question : can I track this file file.c from A and not from B ? Does that even make any sense ? Idea is that any…
Charles
  • 988
  • 1
  • 11
  • 28
1
vote
1 answer

Make git add --patch remember which hunks I've declined to add until the next commit

My common workflow is to do a bunch of code editing, and then use git add --patch to organize my changes into logically consistent commits. A scenario that comes up over and over again is this: I skip a bunch of changes that don't relate to the…
adamesque
  • 1,906
  • 19
  • 24
1
vote
1 answer

Upload files to Gitlab, but show as subproject

I tried to upload a folder the_one_simulator to Gitlab, but the folder is uploaded as a subproject, as shown below. the_one_simulator was originally a repository in Bitbucket. I just copied it into nc_ptn, and ran the following command under…
SparkAndShine
  • 17,001
  • 22
  • 90
  • 134
1
vote
4 answers

how to un-do git add --all followed by multiple commits

I accidentally used git add --all earlier, then made several commits, and it's attempting to add several large files that should be ignored. Now upon any commit, it shows 'this exceeds GitHub's file size limit of 100.00 MB'. I tried git --reset but…
santoku
  • 3,297
  • 7
  • 48
  • 76
1
vote
1 answer

git bash shell on Windows "Your edited hunk does not apply"

I have a very frustrating error when trying to manually edit hunks while using the command: git add -p I have already looked through many of the existing questions on this site, including this one, and this one. I am at the point where I try to…
Atreyu
  • 639
  • 2
  • 7
  • 16