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

Git adding "unchanged" files to the stage

For a project I'm working on, I want to use: git add . -A to add some files to the stage. The problem is that Git thinks these files are unchanged from the last commit, so they are ignored. However, I personally changed the file, but Git still sees…
user2744374
  • 121
  • 1
  • 1
  • 3
12
votes
2 answers

Git add not adding files

when I try to git add my files, I typed git add That works correctly. However, when I try to do git commit -a My git repository tells me that it's empty. What is outputted is: # On branch master # Untracked files: # …
user200081
  • 563
  • 2
  • 12
  • 24
11
votes
3 answers

How to set tab size for hunks in "git add -p"?

I used the solution here to change tab size in git diff output. That works fine with git diff. I have these settings in my .gitconfig: [core] whitespace = tabsize=4,indent-with-non-tab pager = less -FSRX -x4 But those settings seems does not…
Alexander Yancharuk
  • 13,817
  • 5
  • 55
  • 55
10
votes
1 answer

Push Git branches directly into a live server directory so files are seen live

How can I set up remote directories in Git where I can locally push a stage branch to the remote and see the live changes on a staging server, like stage.example.com? The notion I have (part of why I am moving away from SVN) is that I can maintain…
Jannis
  • 17,025
  • 18
  • 62
  • 75
10
votes
1 answer

git add throws warning "CRLF will be replaced by LF in "

I started working on a Xamarin crossplatform development recently. While some of devs in my team are using Mac for development (with Visual Studio for Mac), others are using Windows (with Visual Studio 2017). We use git/github as our code…
cd491415
  • 823
  • 2
  • 14
  • 33
9
votes
1 answer

Git cat staged file to stdout

I have staged parts of a file in git like so git add --patch ./file I would like to output the contents of the staged file to stdout. Note that the staged file and the file in the working directory are different since I only staged parts of the…
Jean Paul Galea
  • 1,321
  • 4
  • 18
  • 26
9
votes
4 answers

Unstage all deleted files in Git

I want to unstage all file deletes. Is there an easy way? I want to apply this to the file pattern of all deletes.
Jacko
  • 12,665
  • 18
  • 75
  • 126
8
votes
2 answers

Git - Can't Push - "! [remote rejected] master -> master (Working directory has unstaged changes)"

I am trying to set up a "simple" git workflow for a Wordpress installation that has a local version, a staging version and a production version. All I want to do is make changes locally and push from local to staging and from local to production. At…
user3826864
  • 429
  • 4
  • 19
8
votes
1 answer

After git rm file; commit -- how to get file back from the remote branch?

I was pulling in my .emacs directory, and hit the following conflict: CONFLICT (add/add): Merge conflict in elisp/dired-details+.el Git status showed the following: Unmerged paths: # (use "git add/rm ..." as appropriate to mark…
Leo Alekseyev
  • 12,893
  • 5
  • 44
  • 44
8
votes
1 answer

How can I make git add -p accept keystrokes without waiting for me to press Enter?

git add -p is very convenient for staging changes in an interactive fashion. At each change, it prompts the user to press a key to determine what Git should do with the change in question: Stage this hunk [y,n,q,a,d,/,K,j,J,g,s,e,?]? Is there…
Anthony Naddeo
  • 2,497
  • 25
  • 28
8
votes
2 answers

Git add Folder with Existing Git Repository

I am making a git repository for my MacVim installation. Some of the plugins in my repository have their own .git folders and repo. The problem is... when I try to add one of these folders to my main repository, it does nothing. My guess: I…
Bryan
  • 17,201
  • 24
  • 97
  • 123
8
votes
2 answers

Manually editing using git add --patch

So, I've got a file I've been working on in branch A, and I'm just about ready to commit it. However, looking at the diff, I think it's better to put it into two separate commits (Well, in this case, two separate branches, maybe). I've used git…
Jason_L_Bens
  • 374
  • 3
  • 14
7
votes
2 answers

Delete git LFS files not in repo

I uploaded some files to git LFS and I went over my storage limit. Now, the files I uploaded don't show up in the repo, but I'm still over my data limit and I can't upload anything.
7
votes
1 answer

Git add on modified file not working, except with -p (patch)

After the first two hours of working all of the sudden, I can't seem to git add one file. Casper@PC2015 MINGW64 /c/Workspace/edoping (develop) $ git add . Casper@PC2015 MINGW64 /c/Workspace/edoping (develop) $ git status On branch develop Your…
Casper Spruit
  • 944
  • 1
  • 13
  • 31
7
votes
4 answers

How to re-add added files (update staged files only) in git?

We have modified files in path/to/another/ and path/to/main/. Files in path/to/main/ already added into git cache but we have updated path/to/main/Bar.php file AGAIN. We now have the following situation: $ git status [...] Changes to be committed: …
Kirby
  • 2,847
  • 2
  • 32
  • 42