-
Notifications
You must be signed in to change notification settings - Fork 6
Git ex1/dorondollev #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f451c7e
5775dab
4491f46
198a3f2
a3b90b5
e640eeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| Git Basics (commit, diff, branches) | ||
| =================================== | ||
| 1. echo 1 > abc.txt | ||
| 2. git status, shows the red color | ||
| 3. git add abc.txt. | ||
| git status, shows the green color | ||
| git commit -m "Committing 1 to abc.txt" abc.txt | ||
| git status, shows the blue color | ||
| 4. echo 2 >>abc.txt | ||
| 5. git status, shows the red color again | ||
| 6. git diff main | ||
| 7. abc.txt file is not indexed yet | ||
| 8. stage2 is ambiguous argument | ||
| 9. git add abc.txt | ||
| 10. git diff shows the difference between the index and the working tree | ||
| Since the changes in abc.txt indexed, it print's nothing | ||
| 11. git diff main | ||
| 12. echo 3 >>abc.txt | ||
| 13. git diff --staged, prints upto the second row which is indexed | ||
| git diff main, prints all tracked changes from local repository to workspace | ||
| 14. The first row is green colored and added to index | ||
| The second row is red colored since the file is in workspace | ||
|
|
||
| Resolve conflicts | ||
| ================= | ||
| 1. | ||
| $ git branch --all | ||
| bugfix/fix_readme_typo | ||
| bugfix/open_kibana_port | ||
| dev | ||
| feature/data_retention_policy | ||
| feature/elasticsearch_helm_chart | ||
| feature/upgrade_angular_version | ||
| feature/version1 | ||
| feature/version2 | ||
| * main | ||
| reset_question | ||
|
|
||
| 2. | ||
| $ git checkout -b feature/lambda_migration | ||
| Switched to a new branch 'feature/lambda_migration' | ||
|
|
||
| 3. | ||
| $ git merge feature/version1 | ||
| Updating d4e8424..1639247 | ||
| Fast-forward | ||
| .env | 0 | ||
| app.py | 4 ++-- | ||
| config.json | 0 | ||
| 3 files changed, 2 insertions(+), 2 deletions(-) | ||
| create mode 100644 .env | ||
| create mode 100644 config.json | ||
|
|
||
| 6. Especailly pay attention to the resolved commit which is the last | ||
| $ git log --name-status HEAD^..HEAD | ||
| commit a64bfcd066f4a3fa06da749b7d7d0842053befe2 (HEAD -> feature/lambda_migr | ||
| ation) | ||
| Merge: 1639247 37b1550 | ||
| Author: doron <doron.dollev@gmail.com> | ||
| Date: Mon May 23 10:23:23 2022 +0300 | ||
|
|
||
| Merge branch 'feature/version2' into feature/lambda_migration | ||
|
|
||
| # Conflicts: | ||
| # app.py | ||
|
|
||
| commit 37b15501505367b8f4a8f8aaea549b134f82e445 (feature/version2) | ||
| Author: Narayan Nadella <narayan.nadella@microsoft.com> | ||
| Date: Mon May 23 09:25:47 2022 +0300 | ||
|
|
||
| Nayaran's changes for app.py | ||
|
|
||
| M app.py | ||
|
|
||
| Cherry picking | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great |
||
| ============== | ||
| 4. .env and config.json | ||
| 5. The answer is yes. | ||
| There may be some kind of dependency. | ||
| for example, if you'll pick a commit that is in progress and it was first introduced in an unpicked commit, | ||
| it won't apply until you'll fix the unordered pick | ||
|
|
||
| Changes in working tree and switch branches | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very good |
||
| =========================================== | ||
| 2. | ||
| $ echo "write some lines in it and add it to the index" >take.txt | ||
|
|
||
| 3. The message suggests that I'll make a commit or stash | ||
| $ git checkout dev | ||
| error: Your local changes to the following files would be overwritten by checkout: | ||
| take.txt | ||
| Please commit your changes or stash them before you switch branches. | ||
| Aborting | ||
|
|
||
| 5. No, this is what it outputs: | ||
| KLITA@DESKTOP-4D3V75O MINGW64 ~/PycharmProjects/myGitEx/07_git_exercises (featur | ||
| e/lambda_migration2) | ||
| $ cat take.txt | ||
| a | ||
| b | ||
| c | ||
|
|
||
| 6. No the file is erased | ||
| Force Checkout clears index and working area from uncommitted changes. | ||
|
|
||
| Reset | ||
| ===== | ||
| 2. | ||
| 1. git resets the last commit, in our case .env changed | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The file |
||
| 2. git resets the index but not the working tree, it means that the files .env and config.json are unadded to index. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, files |
||
| 3. git resets the index and working tree. any untracked files or directories in the way of writing any tracked files are simply deleted | ||
| in our case, init.sh has been deleted and app.py showed. | ||
| 4. git reverts the changes in the last commit in HEAD and create a new commit with the reverted changes | ||
| 3. Changes HEAD according to last history log | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great