Как удалить коммит sourcetree
Перейти к содержимому

Как удалить коммит sourcetree

  • автор:

Как удалить коммит из проекта Sourcetree на github

Я просто переименовал поле в своем проекте, и позже понял, что это привело к сбою моего приложения. Я хочу отменить свою фиксацию на более раннюю фиксацию и отредактировать и написать свой код оттуда. Теперь проблема в том, что когда я сбрасываю ветку до этого коммита и хочу сделать новые нажатия, это говорит мне, что я должен сначала вытащить, потому что ветка находится позади. Я не могу толкаться. Я работаю над Sourcetree в Windows. Есть идеи, как это исправить? https://i.stack.imgur.com/y08cb.jpg Я добавил изображение, чтобы лучше понять здесь. Я хочу сбросить до df .

before changed naming

2 ответа

Если вас не интересуют коммиты после df , вы можете выполнить полный сброс в SourceTree, чтобы зафиксировать df .

Щелкните правой кнопкой мыши df и выберите «сбросить текущую ветку до этой фиксации».
Обратите внимание, что это подразумевает принудительное нажатие, что нормально, если вы единственный, кто работает над этим проектом.

В SourceTree выберите последний «хороший» коммит (то есть тот, который старше того, который вы хотите удалить). Затем позвоните Repository -> Interactive Rebase. . Здесь вы можете изменить полную историю изменений. Когда закончите, нажмите и не забудьте установить флажок «Force Push» внизу диалогового окна.

Если флажок неактивен, вам необходимо сначала включить его: откройте Tools -> Options , вкладку Git . Установите флажок «Включить принудительное нажатие».

Русские Блоги

Гит обучение — SourceTree в директиве Revert: Обратный Commit и сброс коммитов

Инструкция 1. REVERT являетсяУ нового коммита, чтобы отменить фиксацию вы хотите отозваны, так коммит будет добавлен.

В SOURCETREE, если вы хотите, чтобы отменить код, который уже совершал,Вы можете выбрать REVERSE совершить. (Изымать старые фиксации в то время как новая COMMIT)

2. Если вы хотите, чтобы вывести вашу фиксацию, не хотят, чтобы добавить фиксации, не используйте REVERSE COMMIT,Но инструкции использовать СБРОС

3. Сброс, перебазирование, Revert из трех инструкций перебазироваться:

Deleting commits with SourceTree

But I don’t find the right buttons and commands in SourceTree.

3 Answers 3

What you want to do is push your (local) master branch to origin with —force to signify that you want to rewrite history. i.e : you know your changes will cause the origin/master branch to loose history (the 3 commits B, C, D) and you don’t care.

I don’t know sourcetree well enough to tell you if such an operation is possible, the GUI is evolving all the time and they add new functionnality to support more operation every month, but you could always open the git console from sourcetree (at least until 1.3 there was an icon to do that) and enter :

git push —force origin master

This will push your (local) master branch to its tracking branch (which should be origin/master).

N.B: I don’t know how you configured your SourceTree, but if you rely on https to communicate with the server you might have to enter a login/password.

If you also want to remove the origin/test you can do this by right-cliking the branch (under remotes)in sourceTree and selecting delete :

Apparently a GUI option for push —force was/will be added to version 1.7

As a more general answer : Stackoverflow isn’t google. SourceTree is a free commercial software backed by Atlassian. They have support for you. They have an ok’ish manual and a user base sufficient not to be the first newbe to wonder how to do X. Just google it.

How to remove unpushed commits sourcetree?

In the new window, select the commit you want gone, and press the «Delete»-button at the bottom, or right click the commit and click «Delete commit». Click «OK» (or «Cancel» if you want to abort).

How do I remove an Unpushed commit?

Go to Version control window (Alt + 9/Command + 9) — «Log» tab. Right-click on a commit before your last one. pick Soft (. ) push the Reset button in the bottom of the dialog window.

How do I delete a specific commit in SourceTree?

  1. Check out the Dev_1. .
  2. In the commit history graph, find the commit in question.
  3. Next, select the commit immediately before you added the files. .
  4. Right-click that commit, then select «Reset Dev_1. .
  5. In the next dialog, select the «Hard» option and confirm the action.

How do I delete an outgoing commit?

Open the history tab in Team Explorer from the Branches tile (right-click your branch). Then in the history right-click the commit before the one you don’t want to push, choose Reset. That will move the branch back to that commit and should get rid of the extra commit you made.

How do I remove a specific commit in git?

  1. Quick rebase: remove only a specific commit using its id: git rebase —onto commit-id^ commit-id.
  2. Alternatives: you could also try: git cherry-pick commit-id.
  3. Yet another alternative: git revert —no-commit.

1 Git (Sourcetree) : undo or redo commit [local]

18 related questions found

How do I remove a local commit from a branch?

20 Answers. If your excess commits are only visible to you, you can just do git reset —hard origin/<branch_name> to move back to where the origin is. This will reset the state of the repository to the previous commit, and it will discard all local changes.

How do I remove a commit in the middle?

Deleting the «Middle» Commit from the History.

All you need to do is typing «drop» at the beginning of each commit you want to delete. Be careful while using the git rebase command, as it may cause sudden problems. So, it is more recommended to use the git revert command.

How do I undo a commit?

The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD

1” in this case. The last commit will be removed from your Git history.

How do I roll back a commit in SourceTree?

GUI front-ends for git such as SourceTree, has an option to revert a commit. Simply right-click on the commit you wish to undo, and select Reverse commit.

What is reverse commit?

Summary. The git revert command is a forward-moving undo operation that offers a safe method of undoing changes. Instead of deleting or orphaning commits in the commit history, a revert will create a new commit that inverses the changes specified. Git revert is a safer alternative to git reset in regards to losing work .

How do I get rid of all changes in SourceTree?

  1. Click on Reset button from tool bar.
  2. Select multiple file you want to discard.
  3. Click on discard button.

How do I undo a merge commit?

To undo a git merge, you need to find the commit ID of your last commit. Then, you need to use the git reset command to reset your repository to its state in that commit. There is no “git revert merge” command.

What is the difference between revert and reset in git?

Undo Public Commits with Revert

Reverting undoes a commit by creating a new commit. . Contrast this with git reset , which does alter the existing commit history. For this reason, git revert should be used to undo changes on a public branch, and git reset should be reserved for undoing changes on a private branch.

How do I force push in Sourcetree?

Pushing with force

Here’s how to push with force in Sourcetree. Go in “Preferences” and then in the “Advanced” section. Check “Allow force push”. Here’s a force push checkbox, after allowing the feature.

How do I reset a branch to a previous commit?

  1. You could make your current branch to point to the older commit instead. This can be done with git reset –hard f414f31. .
  2. You could also make a new commit that signifies exactly the same state of the venture as f414f31.

How do I cancel push?

  1. checkout the previous commit on that branch using «git checkout»
  2. delete the old branch & push the delete (use git push origin —delete <branch_name> )

How do I undo last push?

If you want to test the previous commit just do git checkout <test commit hash> ; then you can test that last working version of your project. If you want to revert the last commit just do git revert <unwanted commit hash> ; then you can push this new commit, which undid your previous commit.

Does deleting a branch delete commits?

In Git, branches are just pointers (references) to commits in a directed acyclic graph (DAG) of commits. This means that deleting a branch removes only references to commits, which might make some commits in the DAG unreachable, thus invisible.

How do you remove a commit from a branch after push?

Delete a remote commit. To remove a commit you already pushed to your origin or to another remote repository you have to first delete it locally like in the previous step and then push your changes to the remote. Notice the + sign before the name of the branch you are pushing, this tells git to force the push.

How do I delete a git branch?

Delete a branch with git branch -d <branch> . The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn’t been pushed or merged yet. The branch is now deleted locally.

Is git reset safe?

If git revert is a “safe” way to undo changes, you can think of git reset as the dangerous method. . Commit History is one of the ‘three git trees’ the other two, Staging Index and Working Directory are not as permanent as Commits.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *