Skip to content

Instantly share code, notes, and snippets.

@deepanshumehtaa
Last active March 4, 2025 12:56
Show Gist options
  • Save deepanshumehtaa/ffe770ca1d4b7a6e43bee2cbebc51ae5 to your computer and use it in GitHub Desktop.
Save deepanshumehtaa/ffe770ca1d4b7a6e43bee2cbebc51ae5 to your computer and use it in GitHub Desktop.
Uppercase in pycharm: Ctrl+Shift+U
How to Unstage changes?
>> git reset .
>> all red
Remove all unstage changes (remove changes in red)
>> git clean -f
Src: https://devconnected.com/how-to-undo-last-git-commit/
Q: UNDO the Committed Changes:
A:
> git reset --hard HEAD~1
The above will undo the committed changes + delete those changes as well.
But then you need to Force Push your changes, Because we our branch version at local
Has been degraded, and git always welcomes the new higher version and not older version.
But, if you delete the Remote Branch from GIT and push it again,
then your local branch will gets treated as new branch.
Q: How to un-commit but want take those changes to another branch ?
A:
> git reset --soft HEAD~1 # un-commit
> git reset . # un stagged
-OR-
> git restore --staged .
If you want to delete the un-staged changes(don't do this):
> git restore . # don't do this
Transfer changes:
> git stash
Smart Deleting the branch::::::::::::::::::::::::::::::::::::::::::::::::
>> if you have any branch and you already commit (upto c commits) and "pushed"
Make some more changes to commit (c + 1) and you delete that locally using:
>> git branch -D test
IF YOU checkout again to the deleted test branch, it got restore from (c commits)
And not c+1 commits.
Set and Test Upstream
>> git remote add upstream <repo-url-from-where-you-forked>
Pulling the branch directly from upstream
>> git pull upstream <branch-name>
add files to last commit:
>> git add -A
>> git commit --amend --no-edit
Subtree:
# create a new subTree, folder with name of `mySubTree` gets created
git subtree add --prefix=mySubTree [email protected]:dpm07-python/mutual-funds-holdings-harshit.git main
# Update the existing one
git subtree pull --prefix=mySubTree [email protected]:dpm07-python/mutual-funds-holdings-harshit.git main
@deepanshumehtaa
Copy link
Author

deepanshumehtaa commented Apr 6, 2023

changes...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment