-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
# create new file | ||
|
||
**creating new file** | ||
|
||
`$ touch <filename>.md` | ||
|
||
**show status after creating** | ||
|
||
`$ git status | ||
On branch feature/29-stage_and_commit | ||
Untracked files: | ||
(use "git add <file>..." to include in what will be committed) | ||
|
||
new-file.md | ||
|
||
nothing added to commit but untracked files present (use "git add" to track)` | ||
|
||
**file is added to staging area with the content above** | ||
|
||
`$ git add <filename>.md` | ||
|
||
**show status after staging** | ||
|
||
`$ git status | ||
On branch feature/29-stage_and_commit | ||
Changes to be committed: | ||
(use "git reset HEAD <file>..." to unstage) | ||
|
||
new file: new-file.md` | ||
|
||
**show git diff after staging** | ||
|
||
`$ git diff` | ||
|
||
* there's no output for _git diff command_ because it was not included in the last commit and so it cannot be compared. | ||
|
||
# update content | ||
|
||
**doing changes in the already staged file and viewing status** | ||
|
||
`$ git status | ||
On branch feature/29-stage_and_commit | ||
Changes to be committed: | ||
(use "git reset HEAD <file>..." to unstage) | ||
|
||
new file: new-file.md | ||
|
||
Changes not staged for commit: | ||
(use "git add <file>..." to update what will be committed) | ||
(use "git checkout -- <file>..." to discard changes in working directory) | ||
|
||
modified: new-file.md` | ||
|
||
* know the file exists tracked (new file: <filename>) in the staging area and untracked (modified: <filename>) | ||
including the changes made. the changes can be viewed in the output below by using: | ||
|
||
`$ git diff | ||
diff --git a/challenge-010/new-file.md b/challenge-010/new-file.md | ||
index 0633d48..a150316 100644 | ||
--- a/challenge-010/new-file.md | ||
+++ b/challenge-010/new-file.md | ||
@@ -34,6 +34,10 @@ Changes to be committed: | ||
|
||
* there's no output for _git diff command_ because it was not included in the last commit and so it cannot be compared. | ||
|
||
+# update content | ||
+ | ||
+**doing changes in the already staged file and viewing status** | ||
+` | ||
|
||
* the output shows the deletions/insertions made in the file from the working-space compared to the staged file. | ||
|
||
|
||
**staging the changed file and viewing status** | ||
|
||
`$ git add new-file.md | ||
|
||
|
||
$ git status | ||
On branch feature/29-stage_and_commit | ||
Changes to be committed: | ||
(use "git reset HEAD <file>..." to unstage) | ||
|
||
new file: new-file.md` | ||
|
||
* know there's only the new file: <filename>.md with the included changes in the staging area. | ||
|
||
# update content again | ||
|
||
**again we added content to the already staged file** | ||
|
||
`$ git status | ||
On branch feature/29-stage_and_commit | ||
Changes to be committed: | ||
(use "git reset HEAD <file>..." to unstage) | ||
|
||
new file: new-file.md | ||
|
||
Changes not staged for commit: | ||
(use "git add <file>..." to update what will be committed) | ||
(use "git checkout -- <file>..." to discard changes in working directory) | ||
|
||
modified: new-file.md | ||
|
||
|
||
Christian Kluge@Laptop-CK MINGW64 ~/sandbox/challenge-010 (feature/29-stage_and_commit) | ||
$ git diff | ||
diff --git a/challenge-010/new-file.md b/challenge-010/new-file.md | ||
index 9faf384..1c4e571 100644 | ||
--- a/challenge-010/new-file.md | ||
+++ b/challenge-010/new-file.md | ||
@@ -85,6 +85,8 @@ Changes to be committed: | ||
|
||
* know there's only the new file: <filename>.md with the included changes in the staging area. | ||
|
||
+# update content again | ||
+` | ||
|
||
* after adding a new header to the staged file, the file is again staged and unstaged (modified). | ||
* with _git diff_ we view again the changes made compared to the file last staged with _git add <filename>_ | ||
|
||
**staging - commiting - status after commit** | ||
|
||
`git add <filename>.md` | ||
|
||
`$ git commit -m 'added three headers and explanations for staging' | ||
[feature/29-stage_and_commit 6e9b099] added three headers and explanations for staging | ||
1 file changed, 134 insertions(+) | ||
create mode 100644 challenge-010/new-file.md` | ||
|
||
* the output shows the branch we commited: feature/29-stage-and-commit | ||
* the SHA1 checksum of the commit: 6e9b099 | ||
* how many files were changed: 1 | ||
* statistics how many lines were removed and added: 134 insertions | ||
|
||
|
||
`$ git status | ||
On branch feature/29-stage_and_commit | ||
nothing to commit, working tree clean` | ||
|
||
|
||
# using new temporarily branch for copying file from existing branch, deleting original remote and local branch, | ||
# setting up new local branch and pushing to remote | ||
|
||
1. _create new local branch and switch to branch_ | ||
|
||
`$ git checkout feature/29-test | ||
Switched to branch 'feature/29-test'` | ||
|
||
2. _copy file from old branch into new one_ | ||
|
||
`$ git checkout feature/29-stage_and_commit new-file.md | ||
Updated 1 path from de058d9` | ||
|
||
* checking if file is in temporary local branch | ||
|
||
`$ ls -al | ||
total 12 | ||
drwxr-xr-x 1 Christian Kluge 197609 0 Okt 12 13:29 ./ | ||
drwxr-xr-x 1 Christian Kluge 197609 0 Okt 8 09:30 ../ | ||
-rw-r--r-- 1 Christian Kluge 197609 0 Okt 8 09:30 dummy | ||
-rw-r--r-- 1 Christian Kluge 197609 3981 Okt 12 13:29 new-file.md | ||
drwxr-xr-x 1 Christian Kluge 197609 0 Okt 8 17:37 testfolder/` | ||
|
||
3. _deleting remote branch_ | ||
|
||
`$ git push origin --delete feature/29-stage_and_commit | ||
To https://github.com/software-developer-org/sandbox | ||
- [deleted] feature/29-stage_and_commit` | ||
|
||
4. _deleting local branch_ | ||
|
||
`$ git branch -D feature/29-stage_and_commit | ||
Deleted branch feature/29-stage_and_commit (was df23839).` | ||
|
||
5. _creating new branch based on existing branch_ | ||
|
||
`$ git checkout develop | ||
Switched to branch 'develop' | ||
A challenge-010/new-file.md | ||
Your branch is up to date with 'origin/develop'. | ||
|
||
|
||
$ git checkout -b feature/29-stage_and_commit | ||
Switched to a new branch 'feature/29-stage_and_commit' | ||
A challenge-010/new-file.md` | ||
|
||
6. _switch to new branch and delete temporary branch_ | ||
|
||
`$ git branch -D feature/29-test | ||
Deleted branch feature/29-test (was d136b4b).` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|