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
7
votes
2 answers

BitBucket - Create repository and sub modules

I am using bitbucket web interface and have created a new project "Test_Project". In this project, I am able to create a new repository - 'Module1' using Create repository option. Now I want to create repository hierarchy in bitbucket project -…
Jatin
  • 197
  • 2
  • 5
  • 17
7
votes
1 answer

How to add symlinks to git repository on Windows?

I compile binaries for OS X using GitHub' s electron environment and want to add the output to a git repository. I tried git add . error: readlink("sulu.app/Contents/Frameworks/Electron Framework.framework/Electron Framework"): Function not…
Stephan Ahlf
  • 3,310
  • 5
  • 39
  • 68
7
votes
3 answers

How to add an existing nested repo (already checked out in a subdir) to a parent Git repo as a submodule?

What happens if I'm creating the initial commit from my working (parent) directory, but there are subdirs with independently checked-out git repos? I simply did git add . but that brought me to a strange situation when the subdirs with nested Git…
imz -- Ivan Zakharyaschev
  • 4,921
  • 6
  • 53
  • 104
7
votes
3 answers

Git - rm equivalent for "add ."?

If you're using Git from the command line, is there a way to delete in one fell swoop all the files to be deleted in the Changed but not updated list? Rather than doing manual removes using wildcards.
Steve
  • 5,802
  • 12
  • 54
  • 76
7
votes
2 answers

How do I place a dummy file in a git repo?

I'm new at git so please bear with me. Say i have a file under version control that includes sensitive data. Sure enough, I put that file in my .gitignore file, so it doesn't get pushed to the repo. The problem now is somewhere in my project i have…
lightxx
  • 1,037
  • 2
  • 11
  • 29
6
votes
0 answers

Git - Only add files with changed file permissions

I have a lot of files where only the file permissions are different. But some files are actually modified. I would like to add all files where only the file permissions are changed into its own commit. git --version git version 1.8.3.1 git diff…
blablabla
  • 1,468
  • 15
  • 17
6
votes
2 answers

How can I do a git add --patch during an interactive rebase?

I want to go back and remove several portions of a commit that is two commits back. I hoped I could do git rebase -i HEAD^^, edit the commit, and then use git add --patch on the file. However, during the rebase, git reset HEAD
drs
  • 5,679
  • 4
  • 42
  • 67
6
votes
3 answers

'git add .' doesn't work

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…
user723858
  • 1,017
  • 3
  • 23
  • 45
6
votes
3 answers

When one adds an untracked file, does it not go to staged immediately?

In the diagram shown on the git-scm page, Recording Changes to a Repository, it shows that when an untracked file is added, it moves to the unmodified state. Is this correct? If I run $ git add myFile then $ git status, it shows that myFile is…
ataulm
  • 15,195
  • 7
  • 50
  • 92
5
votes
2 answers

Add existing source code folders into Local Git Repository

Let's say I have two existing folders that I want to put under Git source control. One is called CurrentProduction and the other CurrentDevelopment. Would the following steps be correct? Create a new folder called MyProject git init Move the…
Lenard
  • 53
  • 1
  • 3
5
votes
1 answer

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 ..." to unstage) (use "git add ..." to mark resolution) both modified: some_file Now I can git add some_file to mark resolution, as the…
Enlico
  • 23,259
  • 6
  • 48
  • 102
5
votes
3 answers

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 can fix the .gitignore?
Paprika
  • 402
  • 5
  • 18
5
votes
1 answer

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 the interactive patch command. The git diff…
jotik
  • 17,044
  • 13
  • 58
  • 123
5
votes
2 answers

git: store different stages of a file in the index/working tree after conflict

Assume one file is in conflict state with git. It means that the index contains 3 versions of the file, the previous one, the one from one branch, the one from the other branch. I would like to checkout version 3 ("theirs") in the working directory,…
Olivier Verdier
  • 46,998
  • 29
  • 98
  • 90
5
votes
2 answers

Changes not staged for commit even after git add

Here are the git commands which I have typed $ git add -u -n add 'proj1/Foo.scala' $ git add . $ git add . $ git commit -m "message" On branch feature/branch Your branch is up-to-date with 'origin/feature/branch'. Changes not staged for commit: …
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373