How to fix github after a wrong push - github

My team-mate "accidentally" pushed a 2 commits to github breaking our branching model.
I want to revert my github repository as it was.

Here you go:
git clone url project
cd project
git reset HEAD^^ --hard
git push --force

Related

Is there any way to clone a specific brach in git desktop?

I tried but its cloning whole repository. I wanted to clone only specific branch in that repository
Thanks in advance
You only can clone a whole repository except a branch, the code is:
git clone -b mybranch --single-branch git://sub.domain.com/repo.git
If you already have the repository cloned, you can refresh the branch you want, if you have forked the project you can refresh the specific branch you want. the code is:
git checkout 'branch if you want to change to refresh it'
git pull <URL of REPOSITORY> 'branch that you want to refresh it'
git commit -m "message"
git push upstream 'branch that you want to refresh it'

How to remove a commit on repository of GitHub from merge of other repository?

I accidentally merge pull a commit to other repository GitHub ( My local file is not change , this is still correct version). How to remove this version on GitHub? I mean that i revert (update url post ...) 2db249f .Please help me!!
git pull
git rebase -i HEAD~2
git reset --soft HEAD^
git push origin master

Unable to find branch in git repo

In the current directory. I had made a repository yesterday from this directory.
now:
git branch foo
After doing some changes in the file..
git add .
git commit -m "commit1"
git push.
I am unable to see the branch from my repo on github. While git branch does show this foo.
What you did is creating a local branch;
you will need alternatively to make it a remote branch:
git push <remote-name> <branch-name>
where <remote-name> is usually origin

git / github unresolved conflicts but no visible differences

I am using eclipse, git and github. A friend of mine forked my github repo and changed some code. There was a pull request, I accepted the changes to my github repo. Now I tried to commit my own files and I am not able to 'commit and push'. As you can see in my screenshot there are no visible differences in the file. What procedure will solve this conflict?
Assuming your friend's work got merged into master and you are on branch your-feature-branch then:
git checkout master
git pull
git checkout your-feature-branch
git rebase master
will attempt to rebase your work on top of master, which already includes your friend's changes. The rebase procedure will process your commits one at a time and inform you of any conflicts which you can then resolve. Each file with conflicts will have conflict markers that tell you the changes introduced by each branch. After resolving the conflicts stage your changes then do
git rebase --continue
Repeat until rebase finishes. If at any point you become confused you can always abandon the rebase with
git rebase --abort
Once your work is rebased push your-feature-branch to origin, open a pull request, then merge.
I got the same issue sometimes, without a visible reason. Using a git rm on the directory containing the bad file, followed by a git reset --hard solved the issue for me.
git rm --cached -r DIRECTORY
git reset --hard

Messed up my master branch on Github

While contributing to a github project that I had folked. I committed my changes to the master branch of my repo. By mistake I did a pull from the Project's repo. Now while I do a PR from my repo, it includes those changes too. I dont want that to happen, can anyone help?
Just reset your local master and push it back.
$ git checkout master
$ git reset <last_good_commit>
$ git push