Frage

After I committed files in Git, I made a pull request but it stops some of my code functionality. I want to go to the previous stage, before I committed my files, the state previous to this pull request.

I found git stash is an option to go to previous stage. But there are many options given with it like

git --rebase
git stash
git stash pop

Other commands I've tried include:

git status
git commit file1 file2 file3 -m "message"
git commit -i file1 file2 file3 "message"
git pull
git checkout 

Which commands do I need to use to go to the stage before pull?

War es hilfreich?

Lösung 2

You have to use git stash beforehand. If you didn't, you can try to guess your previous state by running git log -g.

Among the results find commits with "message". One of them is what you're looking for.

Andere Tipps

I think you mix pull and pull request. Pull request is a GitHub request to repository owner to grab some of your commits and apply those to his repository. git pull on the other hand is a process updating your local repository with new changes from the associated remote repository.

WARNING: BACKUP YOUR LOCAL REPOSITORY FIRST.

To recover from possible problems in your case you can try:

  • git reset --hard reset on going merge process. This will remove all staged (git added) changes and all local changes.
  • git rebase --abort reset ongoing rebase process, in case you started one issuing git rebase or git pull --rebase

After you cleaned up your repository I suggest, you do

git fetch

to make sure you are up-to-date with the remote repository. Then you can use gitk --all to visualize the history examining all branches. I suppose, you will see, that the origin/master branch is ahead of your local commits. In order to push your changes you will have to merge or better rebase. To do this checkout your local changes with

git checkout master

(replace master with your local branch) and then issue

git rebase origin/master

(replace master with your target remote branch). If you get merge conflicts you will have to resolve it, then git add changed files and then continue rebase process with

git rebase --continue

Now you can push your changes with

git push origin master:master

(replace master with your local branch and second master with your remote branch)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top