How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?

Getting back in synch after a pushed rebase is really not that complicated in most cases. git checkout foo git branch old-foo origin/foo # BEFORE fetching!! git fetch git rebase –onto origin/foo old-foo foo git branch -D old-foo Ie. first you set up a bookmark for where the remote branch originally was, then you use … Read more

I need to pop up and trash away a “middle” commit in my master branch. How can I do it?

Rebase or revert are the options. Rebase will actually remove the commit from the history so it will look like that second commit never existed. This will be a problem if you’ve pushed the master branch out to any other repos. If you try to push after a rebase in this case, git will give … Read more

What is difference between ‘git reset –hard HEAD~1’ and ‘git reset –soft HEAD~1’?

git reset does know five “modes”: soft, mixed, hard, merge and keep. I will start with the first three, since these are the modes you’ll usually encounter. After that you’ll find a nice little a bonus, so stay tuned. Let’s assume you have a repository with a history akin to this: 7e05a95 (HEAD -> main) … Read more

Why git can’t do hard/soft resets by path?

Because there’s no point (other commands provide that functionality already), and it reduces the potential for doing the wrong thing by accident. A “hard reset” for a path is just done with git checkout HEAD — <path> (checking out the existing version of the file). A soft reset for a path doesn’t make sense. A … Read more

What is the `git restore` command and what is the difference between `git restore` and `git reset`?

I have presented git restore (which is still marked as “experimental”) in “How to reset all files from working directory but not from staging area?”, with the recent Git 2.23 (August 2019). It helps separate git checkout into two commands: one for files (git restore), which can cover git reset cases. one for branches (git … Read more

Undo “git add ”?

To remove a directory and everything inside it from the index, git rm –cached -r dir The –cached switch makes git rm operate on the index only and not touch the working copy. The -r switch makes it recursive.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)