From bce2f0dd276460fb66f8591c9022c6604672e1ef Mon Sep 17 00:00:00 2001 From: KarthikSiddarth Date: Wed, 30 Oct 2019 18:08:19 +0530 Subject: [PATCH] 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 --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 00fe8cf..44be4b6 100644 --- a/README.md +++ b/README.md @@ -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 + + +### 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/ +``` + ### 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 -- +$ git checkout -- ``` ### Restore a deleted file