Tip 1: Move existing, uncommitted work to a new branch in Git https://overflow.smnz.de/questions/1394797/move-existing-uncommitted-work-to-a-new-branch-in-git > git switch -c <new-branch>
git cherry-pick -n <hash>
git cherry-pick -m 1 <hash>
# Ako sam push-ovao na remote repozitorijum, a
# onda uradim git reset HEAD~, da bi to gurnuo na remote granu
git push origin [-u] main --force
Git magic (ceo sajt je dobar: lex in go, haskell itd)
What’s the difference between Git Revert, Checkout and Reset?
When do you use Git rebase instead of Git merge?
How to remove files that are listed in the .gitignore but still on the repository?
How to combine new changes with previous commit in git
You can remove them from the repository manually:
git rm --cached file1 file2 dir/file3
Or, if you have a lot of files:
git rm --cached `git ls-files -i -c --exclude-from=.gitignore`
But this doesn't seem to work in Git Bash on Windows. It produces an error
message. The following works better:
git ls-files -i -c --exclude-from=.gitignore | xargs git rm --cached
In PowerShell on Windows this works even better (handles spaces in path and
filenames):
git ls-files -i -c --exclude-from=.gitignore | %{git rm --cached $_}
git rm -r --cached .
git add .
git commit -m "Drop files from .gitignore"
One way is to use git reflog, it will list all the HEADs you've had. I find that
git reflog --relative-date is very useful as it shows how long ago each change
happened.
git reflog --relative-date
How to combine new changes with previous commit in git
git add -u && git commit --amend
git remote set-url origin git://new.url.here
git remote remove origin
git remote -v
git remote set-url origin new.git.url/here
git remote -v
Changing git commit message after push: - If it is the most recent commit, you can simply do this: git commit --amend
link ka pitanju
git reset --hard HEAD~1
git reset --hard HEAD~3
git reset --hard <hash>
git push origin HEAD --force
!!!git reset --hard CommitId
git push -f origin master
git config --global diff.tool vimdiff
git config --global difftool.prompt false
1st command will rest your head to commitid and 2nd command will delete all commit after that commit id on master branch.
git config --global diff.tool vimdiff
git config --global difftool.prompt false