- Home
-
HTML
HTML Introduction HTML Tags HTML Elements HTML Attributes HTML Heading HTML Paragraph HTML Formatting HTML Quotations HTML Comments HTML Styles HTML Color HTML CSS HTML Images HTML Favicon HTML Links HTML DIV HTML Tables HTML Table Size HTML Table Head Table Padding & Spacing Table colspan rowspsn HTML Table Styling HTML Colgroup HTML List HTML Block & Inline HTML Classes HTML Id HTML Iframes HTML Head HTML Layout HTML Semantic Elements HTML Style Guide HTML Forms HTML Form Attribute HTML Form Element HTML input type HTML Computer code HTML Entity HTML Symbol HTML Emojis HTML Charset HTML Input Form Attribute HTML URL Encoding
-
CSS
CSS Introduction CSS Syntax CSS Selector How To Add CSS CSS Comments CSS Colors CSS Background color CSS background-image CSS Borders CSS Margins CSS Height, Width and Max-width CSS Box Model CSS Outline CSS Text CSS Fonts CSS Icon CSS Links CSS Tables CSS Display CSS Maximum Width CSS Position z-index Property
- JavaScript
-
JQuery
What is jQuery? Benefits of using jQuery Include jQuery Selectors. Methods. The $ symbol and shorthand. Selecting elements Getting and setting content Adding and removing elements Modifying CSS and classes Binding and Unbinding events Common events: click, hover, focus, blur, etc Event delegation Using .on() for dynamic content Showing and hiding elements Fading elements in and out Sliding elements up and down .animate() Understanding AJAX .ajax() .load(), .get(), .post() Handling responses and errors. Parent Chlid Siblings Filtering Elements Using find Selecting form elements Getting form values Setting form values Form validation Handling form submissions jQuery plugins Sliders plugins $.each() $.trim() $.extend() Data attributes Debugging jQuery code
-
Bootstrap 4
What is Bootstrap Benefits of using Setting up Container Row and Column Grid Classes Breakpoints Offsetting Columns Column Ordering Basic Typography Text Alignment Text colors Backgrounds Display Font Size Utilities Buttons Navs and Navbar Forms Cards Alerts Badges Progress Bars Margin Padding Sizing Flexbox Dropdowns Modals Tooltips Popovers Collapse Carousel Images Tables Jumbotron Media Object
- Git
-
PHP
PHP Introduction PHP Installation PHP Syntax PHP Comments PHP Variable PHP Echo PHP Data Types PHP Strings PHP Constant PHP Maths PHP Number PHP Operators PHP if else & if else if PHP Switch PHP Loops PHP Functions PHP Array PHP OOps PHP Class & Object PHP Constructor PHP Destructor PHP Access Modfiers PHP Inheritance PHP Final Keyword PHP Class Constant PHP Abstract Class PHP Superglobals PHP Regular Expression PHP Interfaces PHP Static Method PHP Static Properties PHP Namespace PHP Iterable PHP Form Introduction PHP Form Validation PHP Complete Form PHP Date and Time PHP Include Files PHP - Files & I/O File Upload PHP Cookies PHP SESSION PHP Filters PHP Callback Functions PHP JSON PHP AND Exceptions PHP Connect database
-
MY SQL
SQL Introduction Syntax Select statement Select Distinct WHERE Clause Order By SQL AND Operator SQL OR Operator SQL NOT Operator SQL LIKE SQL IN SQL BETWEEN SQL INSERT INTO SQL NULL Values SQL UPDATE SQL DELETE SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause SQL MIN() and MAX() Functions SQL COUNT() Function SQL SUM() SQL AVG() SQL Aliases SQL JOIN SQL INNER JOIN SQL LEFT JOIN SQL RIGHT JOIN SQL FULL OUTER JOIN SQL Self Join SQL UNION SQL GROUP BY SQL HAVING SQL EXISTS SQL ANY and ALL SQL SELECT INTO SQL INSERT INTO SELECT SQL CASE SQL NULL Functions SQL Stored Procedures SQL Comments SQL Operators SQL CREATE DATABASE SQL DROP DATABASE SQL BACKUP DATABASE SQL CREATE TABLE SQL DROP TABLE SQL ALTER TABLE SQL Constraints SQL NOT NULL SQL UNIQUE Constraint SQL PRIMARY KEY SQL FOREIGN KEY SQL CHECK Constraint SQL CREATE INDEX SQL AUTO INCREMENT SQL Dates SQL Views SQL Injection SQL Hosting SQL Data Types
Undoing changes in Git
Undoing changes in Git can be approached in several ways, depending on what you want to achieve. Here's a detailed overview:
1. Undoing Uncommitted Changes
a. Undoing Changes in Tracked Files
-
To discard changes in a tracked file (revert to the last commit):
git checkout -- <file>
This command discards all modifications in the specified file and restores it to the state it was in at the last commit.
-
To discard all changes in all files (revert to the last commit):
git reset --hard
This command will discard all uncommitted changes in your working directory.
b. Unstaging Changes
If you have staged changes (added to the index) but haven't committed them yet:
-
To unstage a specific file:
git reset <file>
This command removes the file from the staging area but keeps the changes in your working directory.
-
To unstage all files:
git reset
This will unstage all files but leave the changes in your working directory.
2. Undoing Committed Changes
a. Amending the Last Commit
If you need to modify the most recent commit (e.g., add more changes or correct a commit message):
- To amend the last commit:
This will open the commit message editor so you can update the commit message or include new changes.git commit --amend
b. Reverting a Commit
If you need to undo a commit without modifying history (ideal for public branches):
- To revert a specific commit:
This creates a new commit that undoes the changes introduced by the specified commit.git revert <commit-hash>
c. Resetting to a Previous Commit
If you want to undo commits and move the branch pointer to an earlier commit:
-
To reset to a specific commit (keeping changes in working directory):
git reset <commit-hash>
This will move the branch pointer to the specified commit but keep your working directory changes.
-
To reset to a specific commit and discard all changes (dangerous):
git reset --hard <commit-hash>
This command will move the branch pointer to the specified commit and discard all changes in the working directory.
3. Undoing Changes in a Branch
a. Deleting a Branch
If you want to undo everything on a branch and start fresh:
-
To delete a local branch:
git branch -d <branch-name>
Use
-D
(uppercase) if the branch hasn’t been merged and you want to force delete it. -
To delete a remote branch:
git push origin --delete <branch-name>
b. Creating a New Branch from a Previous Commit
If you want to create a new branch starting from a previous commit:
- To create a new branch from a specific commit:
This creates a new branch starting from the specified commit.git checkout -b <new-branch-name> <commit-hash>
Important Notes
- Use with Caution: Commands like
git reset --hard
andgit clean
can permanently discard changes, so use them with caution. - Backup: It’s often a good idea to create a backup branch before performing destructive operations.
These are the core methods for undoing changes in Git. Each method serves a different purpose, so choose the one that best fits your situation.
At Online Learner, we're on a mission to ignite a passion for learning and empower individuals to reach their full potential. Founded by a team of dedicated educators and industry experts, our platform is designed to provide accessible and engaging educational resources for learners of all ages and backgrounds.
Copyright 2023-2024 © All rights reserved.