Revert already pushed commit

Revert already pushed commit

Revert already pushed commit How do I use ‘git reset –hard HEAD’ to revert to a previous commit? - Stack Overflow

Move the most recent commit(s) to a new branch with Git - Stack Overflow

git push –all origin This will push tags and branches. version control - Set up git to pull and push all branches - Stack Overflow

Usual: How to revert to a previous commit when you’ve already pushed your changes

On undoing, fixing, or removing commits in git Git Revert | Atlassian Git Tutorial Resetting, Checking Out & Reverting | Atlassian Git Tutorial

Learning to use GIT

Git? Git Tutorial for Beginners: Basic Git Commands – IT Stuff – Medium Git Tutorial for Beginners: Remote Repository Management Commit Often, Perfect Later, Publish Once—Git Best Practices

Windows & Git Line Endings

git config --global user.email "vladan.colovic@fairwalter.ch"
git config --global user.name "Vladan Colovic"
git config --global core.autocrlf true

Display Git config and see where that setting is defined (global, user, repo, etc)

git config --list --show-origin

Better aproach

Better way is to set line endings handling in repository using .gitattributes

.gitattributes Documentation

echo "* text=auto !eol" >.gitattributes
git add --renormalize .
git status # Show files that will be normalized
git commit -m "Introduce end-of-line normalization"

* text=auto !eol All files have the attribute text set to auto and the eol attribute unspecified. Reading the documentation we find out that text=auto means that you let git decide if a file is text and if it is it will normalize it (set line-endings in the repo to LF

Easier explanation: https://stackoverflow.com/a/21302915/586898

More: https://www.reddit.com/r/git/comments/4da6jq/gitattributes_textauto_eol/ https://stackoverflow.com/questions/21472971/what-is-the-purpose-of-text-auto-in-gitattributes-file

1
2
3
4
5
6
7
8
git init
echo "* text=auto !eol" >.gitattributes
git add .
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:user/repo.git
git status
git push -u origin main
1
2
3
4
5
6
echo "/public" >>.gitignore
echo "/resources" >>.gitignore

# option "-b" defines branch on submodule that will be tracked
git submodule add -b master git@github.com:zzossig/hugo-theme-zdoc.git themes/zdoc
git submodule add -b main git@github.com:cvladan/notes.git content
1
2
3
4
5
# this is pull together with submodules, but it's not pulling the latest commit
git pull --recurse-submodules

# will update to latest commit on branch in submodules
git submodule update --remote

It’s a little confusing, but submodules are not on a branch. They are just a pointer to a particular commit of the submodule’s repository. So when someone else checks out your repository or pulls your code, and does git submodule update, submodule is checked out to that particular commit.

The thing that the -b option gives us is the ability to add --remote flag to your update directive: git submodule update --remote

Also, please research setting an option: git config --global submodule.recurse true

Multiple Deploy Keys in repo and submodules on GitHub

Lots of discussion on solution to this problem…

How to configure multiple deploy keys for different private github repositories

Perfect solutions for multiple deploy keys on submodule

Amazing idea is to create a command, eg custom_keys_git_ssh and used it in GIT_SSH_COMMAND variable instead direct ssh. Intercept that and automatically load appropriate keys when loaded.

That idea is implemented here: Multiple ssh deploy keys with git and it is perfect!

date 27. Aug 2019 | modified 28. May 2021
filename: Git » Dump