Note/git add u (#287)

* add note about 'git add -u '

* run doctoc

* add note about copying folder

* add space b/w -- and folder name

also mention, this can be done for files

* add 'file' in the title

* add node on using pathspec

* run doctoc

* fix small errors

* run doctoc

* remove 'my-branch' text
This commit is contained in:
KarthikSiddarth 2019-10-30 18:08:19 +05:30 committed by Richard Littauer
parent f0b433773f
commit bce2f0dd27
1 changed files with 21 additions and 1 deletions

View File

@ -48,6 +48,8 @@ All commands should work for at least git version 2.13.0. See the [git website](
- [Final Step: Pushing your changed repo history](#final-step-pushing-your-changed-repo-history)
- [I need to change the content of a commit which is not my last](#i-need-to-change-the-content-of-a-commit-which-is-not-my-last)
- [Staging](#staging)
- [I want to stage all tracked files and leave untracked files](#i-want-to-stage-all-tracked-files-and-leave-untracked-files)
- [To stage part of tracked files](#to-stage-part-of-tracked-files)
- [I need to add staged changes to the previous commit](#i-need-to-add-staged-changes-to-the-previous-commit)
- [I want to stage part of a new file, but not the whole file](#i-want-to-stage-part-of-a-new-file-but-not-the-whole-file)
- [I want to add changes in one file to two different commits](#i-want-to-add-changes-in-one-file-to-two-different-commits)
@ -562,6 +564,24 @@ will do the rest of the work for you.
## Staging
<a href="#i-want-to-stage-all-tracked-files-and-leave-untracked-files"></a>
### I want to stage all tracked files and leave untracked files
```sh
$ git add -u
```
#### To stage part of tracked files
```sh
# to stage files with ext .txt
$ git add -u *.txt
# to stage all files inside directory src
$ git add -u src/
```
<a href="#i-need-to-add-staged-changes-to-the-previous-commit"></a>
### I need to add staged changes to the previous commit
@ -1595,7 +1615,7 @@ $ rm -rf .git/modules/submodulename
### Copy a folder or file from one branch to another
```sh
$ (my-branch)$ git checkout <branch-you-want-the-directory-from> -- <folder-name or file-name>
$ git checkout <branch-you-want-the-directory-from> -- <folder-name or file-name>
```
### Restore a deleted file