forked from firstcontributions/first-contributions
-
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.
Merge branch 'master' into Pro-first-contributions
- Loading branch information
Showing
5 changed files
with
105 additions
and
18 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
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,18 @@ | ||
## Useful Links | ||
|
||
This document is dedicated to all the blog posts, helpful sites, tips and tricks websites that makes our lives easier. That we refer to for all our needs, be it a beginner or an expert. This page should act as an index of all those useful links that would help everybody who is new in the open-source domain or someone who wants to learn more. | ||
|
||
## The List | ||
1. ![Interactive tutorial to git](https;//try.github.io) | ||
2. ![git - the simple guide](http://rogerdudler.github.io/git-guide/) | ||
3. ![On undoing, fixing, or removing commits in git](http://sethrobertson.github.io/GitFixUm/fixup.html) | ||
4. ![Git and GitHub tutorial translated to many languages](https://github.com/Roshanjossey/first-contributions) | ||
5. ![Merge Conflicts](https://www.git-tower.com/learn/git/ebook/en/command-line/advanced-topics/merge-conflicts) | ||
6. ![Resolving Merge Conflicts](https://githowto.com/resolving_conflicts) | ||
7. ![Git cheat sheet](https://www.git-tower.com/learn/cheat-sheets/git) | ||
8. ![Common Git Problems](https://www.codementor.io/citizen428/git-tutorial-10-common-git-problems-and-how-to-fix-them-aajv0katd) | ||
9. ![Git Rebase](https://blog.gitprime.com/git-rebase-an-illustrated-guide/) | ||
10. ![Beginner's Guide to Rebasing and Squashing](https://github.com/servo/servo/wiki/Beginner%27s-guide-to-rebasing-and-squashing) | ||
|
||
|
||
Keep adding more links, that you find helpful. |
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
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,55 @@ | ||
## Undo local commits | ||
|
||
To undo a local commit, all you need to do is | ||
``` | ||
git reset | ||
``` | ||
This command will reset your staging area to your most recent commit, but the changes you made to your working directory will not change. So, you can still re-commit again what you've changed. | ||
Or, if you only want to remove one file from your previous commit. Then, you can do the command below | ||
``` | ||
git reset <file> | ||
``` | ||
The command will remove only the specified file from the staging area, but changes made on the file still remained. | ||
|
||
Example of ```git reset``` usage | ||
``` | ||
# Make changes in index.php and tutorial.php | ||
# Add files into the staging area | ||
$ git add . | ||
# Remembered both files need to be committed separately | ||
# Unstage tutorial.php | ||
$ git reset tutorial.php | ||
# Commit index.php first | ||
$ git commit -m "Changed index.php" | ||
# Commit tutorial.php now | ||
$ git add tutorial.php | ||
$ git commit -m "Changed tutorial.php" | ||
``` | ||
|
||
Let's say if you have messed up your local repository and you just want to reset it to your last commit. | ||
Then, you can run the command below. | ||
``` | ||
git reset --hard | ||
``` | ||
The command will not only reset your staging area, but also revert all your changes on the files to your last commit. | ||
The mode ```--hard``` tells Git to undo all the changes in the working directory too. | ||
You should only run this when you are really sure of throwing your whole local development out. | ||
|
||
Example of ```git reset --hard``` usage | ||
``` | ||
# Decided to start a crazy experiment | ||
# Create a new file 'crazy.php' and add some code to it | ||
# Commit crazy.php | ||
$ git add crazy.php | ||
$ git commit -m "Started a crazy dev" | ||
# Edit crazy.php file again and changed a lot other files | ||
# Commit all tracked files | ||
$ git add . | ||
$ git commit -m "Continued dev" | ||
# Tested and things went out of hand | ||
# Decided to remove the whole things | ||
$ git reset --hard HEAD~2 | ||
``` | ||
The ```git reset --hard HEAD~2``` moves the current branch backward by 2 commit points in the same time reverting all changes you have made and remove the 2 snapshost we have just created from project history. | ||
|
||
P.s. Never perform ```git reset --hard``` if you've already pushed your commits to a shared repository as it will cause problems to everyone on that repository. |
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