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
0 answers

Connecting to web hosting site via git in such a way that I can push and pull directly via my local pc

I initialized a bare repository on server git init --bare and then added a remote git remote add origin my.hosting.website.com:my-repository.git then I am trying to pull.I used pull -all my repo on server Problem is when I try to…
Adi
  • 43
  • 10
1
vote
2 answers

Can git ever send your code to a repo that isn't yours?

Can running git add . git commit -m "message" in a git repo which you've initialized using git init ever result in your code being sent to a repo that is not yours? I am concerned because I did this while not logged in to my git hub account.
yaboi
  • 301
  • 1
  • 7
  • 20
1
vote
1 answer

git add all tracked files - also those in parent directory

Lets say I have a git root folder mine_git, which has a subdirectory subdir there. So I've worked a bit, and I'm in subdir - git status lists all changed files: subdir$ git status -uno # On branch master # ... # # modified: mysubdirfile.txt # …
sdaau
  • 36,975
  • 46
  • 198
  • 278
1
vote
1 answer

Can git break up changes by default?

I like to use the -p flag on several git commands, such as add, reset, checkout, and stash. But git groups somewhat contiguous changes together in the same hunk. I know that s breaks up the changes but is there another option I could pass to have…
user4316237
1
vote
1 answer

“git rm .” is not adding the deleted files in the staged area

I eliminated some files of my project. I want to pass all the eliminated files to staging area with some as git rm ., but I want to pass all the files at once using wildcards. What's the good way to stage the eliminated…
daniel barrera
  • 347
  • 1
  • 4
  • 15
1
vote
0 answers

Git - unable to add files to repo

I am new to Git and GitHub. I have created a public repository username/test_files in Github. On my local machine, I have created a similar folder /users/username/test_files I created a new test.md file and saved it under /test_files on my local…
Free your mind
  • 47
  • 1
  • 1
  • 7
1
vote
1 answer

Git add -e without requiring arithmetic logic on hunk headers

I have made a few changes to a branch on my git repository. However, I would like to add/stage those changes in batches of different commits. For this, I usually add files with the -e or -p flag to include only the bits I want. Unfortunately, this…
zanona
  • 12,345
  • 25
  • 86
  • 141
1
vote
2 answers

What is the svn equivalent for "git add -u"?

Is there an equivalent in svn like git add -u? Basically, stage all the tracked files?
David Liu
  • 16,374
  • 12
  • 37
  • 38
1
vote
2 answers

Git-add : Marking files to add without entering full path

Does anyone knows a cli utility or command that allow to quickly mark files to add to the next commit or rebase ? For now i have to do : git add $fullPath0 $fullPath1 $fullPath2... I heard that "tig" can open a window where you can add files with…
Manel
  • 1,616
  • 19
  • 42
1
vote
1 answer

Interactive adding: Don't add lines with specific pattern

I'm currently working on a large legacy project which undergoes quite some refactoring. As you can guess this also means lots of deletions etc.. At the moment I'm removing a specific feature which has become obsolet, so I want to keep my changes…
Sascha Wolf
  • 18,810
  • 4
  • 51
  • 73
1
vote
1 answer

Git: Creating alias for "add --update TOPLEVEL_DIR"?

I often find myself typing git add -u with the intention of adding everything that is modified but tracked in the whole repository. However, it gets annoying and tedious when I'm in a subdirectory. For example if all my modifications are in src/…
eold
  • 5,972
  • 11
  • 56
  • 75
1
vote
1 answer

Git deleting files without using git rm

Often I'll delete a file (via Finder) while dealing with merge conflicts. When I go to conclude my merge, I try git rm my_file.txt and I get an error that fatal: unable to stat 'my_file.txt': No such file or directory. Do I have to go to the CLI…
Don P
  • 60,113
  • 114
  • 300
  • 432
1
vote
2 answers

Adding files to repository for the first time

Kiddie question here -- I've read all kinds of posts about git add and can't find this situation. I've been working on some files on my own computer without even thinking about Git or version control and I just now created a repository on Github to…
dlb8685
  • 351
  • 3
  • 10
1
vote
1 answer

Add files to .git and do not delete them when pushing to upstream

I am looking into adding some files to .git repo directory, and push them to the upstream without tracking/commiting them. Example: .git/information.txt After I do a commit, I add text to information.txt, and then push. When I clone/fork I would…
scas
  • 221
  • 2
  • 9
1
vote
2 answers

git add - Avoid adding files from subdirectories using wildcards when no pattern matches in current directory

git add *.c is supposed to add matching files only from the current directory, not from its subdirectories. I noticed that if no file matches the searched pattern in the current directory, git add *.c is adding matching files from…
tkarra
  • 541
  • 3
  • 8