René's URL Explorer Experiment


Title: Feature: Add functionality to discard changes · Issue #356 · github-for-unity/Unity · GitHub

Open Graph Title: Feature: Add functionality to discard changes · Issue #356 · github-for-unity/Unity

X Title: Feature: Add functionality to discard changes · Issue #356 · github-for-unity/Unity

Description: GitHub for Unity. Contribute to github-for-unity/Unity development by creating an account on GitHub.

Open Graph Description: GitHub for Unity. Contribute to github-for-unity/Unity development by creating an account on GitHub.

X Description: GitHub for Unity. Contribute to github-for-unity/Unity development by creating an account on GitHub.

Opengraph URL: https://github.com/github-for-unity/Unity

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature: Add functionality to discard changes","articleBody":"# Discarding changes\r\n\r\n## Problem\r\n\r\nWhen there are changes to files that the user isn't interested in keeping, they need a way of throwing away these changes. This is normally implemented via a `Discard` action for a specific file, or for all files. \r\n\r\n### Git overview\r\n\r\nGit provides a `checkout` command that changes the working directory back to a previous state. This command can take:\r\n\r\n- a commit (usually a branch name) - updates the working directory to the state of that commit\r\n- a filename or list of files - updates the named files to the state of the commit (the current HEAD if no commit is specified)\r\n\r\n`git checkout [file]` or `git checkout -- [files]`, will only operate on files that are already tracked by git and will not work for new files. Also, if a file has already been added to the staging area, `checkout [file]` will not affect the changes in the staging area, it will only affect changes that have not been staged yet.\r\n\r\n![image](https://user-images.githubusercontent.com/310137/31720974-5b9b31a4-b418-11e7-89cc-d04c49f5e26b.png)\r\n\r\nIn this situation above, in order to discard changes to the different files, we need to do:\r\n\r\n- **README.me**: `git checkout HEAD -- README.md` \r\n- **package.sh**: `git checkout -- package.sh` (`git checkout HEAD -- package.sh` also works)\r\n- **a**: `git checkout` won't work, we need to manually delete the file. \r\n\r\n`git clean -f` throws away new files / changes to untracked files, but won't reset tracked file changes back to what they were.\r\n\r\n`git reset --hard` throws away all changes to tracked files but doesn't touch untracked (new) files\r\n\r\n## Solution\r\n\r\n### Technical backend - git operations\r\n\r\n#### Discard changes to a single file\r\n\r\nTo implement \"Discard changes to a particular file\", we should:\r\n\r\n- Check whether the file is new\r\n\t- If yes, delete it\r\n\t- If no, `git checkout HEAD -- [file]`\r\n\r\n#### Discard changes to all files\r\n\r\nTo implement \"Discard all changes\", there's several alternatives:\r\n\r\n1. **clean and reset**\r\n- Run `git clean -f` to throw away all new (untracked) files\r\n- Run `git reset --hard` to reset all changed (tracked) files back to unchanged\r\n\r\n2. **checkout and delete**\r\n- Categorize all files by new/existing (untracked/tracked)\r\n- Delete all new (untracked) files\r\n- Run `git checkout HEAD -- [files]` on all existing (tracked) changed files\r\n\r\n### UI/UX\r\n\r\nTBD\r\n\r\n### API technical details\r\n\r\nGiven that both discard and discard all requires at least two separate actions (as talked about in https://github.com/github-for-unity/Unity/issues/356), that should probably be implemented in `RepositoryManager`. What we then need is:\r\n\r\n**`RepositoryManager.cs` (pseudocode)**:\r\n\r\n```\r\nDiscardAll():\r\n\r\n   GitClient.CleanUntrackedFiles()\r\n   GitClient.Checkout(\"HEAD\")\r\n```\r\n\r\n```\r\nDiscardFiles(List\u003cGitFile> files):\r\n   \r\n    where file in files.Added: Delete File via System.IO calls\r\n    all other files: GitClient.Checkout(\"HEAD\", files)\r\n```\r\n\r\nWe already have `GitSwitchBranchesTask` which basically does a `git checkout`. We should probably rename that one to `GitCheckout` and add an optional `files` parameter to it, calling either `git checkout [branch]` or `git checkout [branch] -- files` depending on whether there's a list of files to checkout. Checking out a branch is the same as checking out `HEAD`, there's no difference there\r\n\r\n\r\n**old issue body below**\r\n----\r\n\r\nTo implement a discard changes function in the user interface we first need to add the functionality to our api.\r\n\r\n1. Create `GitCheckoutTask`,\r\n  a. The goal of this task is to run `git checkout`.\r\n    1. It should be able to checkout on a specific file\r\n      `git checkout path/to/file/to/revert`\r\n    2. It should be able to checkout all files\r\n      `git checkout -- .`\r\n  b. You can use `GitAddTask` as an example.\r\n     https://github.com/github-for-unity/Unity/blob/master/src/GitHub.Api/Git/Tasks/GitAddTask.cs\r\n2. Add the functionality to use `GitCheckoutTask` to `GitClient`\r\n  a. Create a `Discard` and `DiscardAll` method\r\n  b. You can use the methods `Add` and `AddAll` as an example\r\n    https://github.com/github-for-unity/Unity/blob/master/src/GitHub.Api/Git/GitClient.cs#L371-393\r\n3. Add some integration tests\r\n  https://github.com/github-for-unity/Unity/blob/master/src/tests/IntegrationTests/Events/RepositoryManagerTests.cs\r\n  a. We need some integration tests to prove what you did is working correctly\r\n  b. You can use the `ShouldDetectFileChanges` test as an example, it makes changes to the system and checks if they are there.\r\n  https://github.com/github-for-unity/Unity/blob/master/src/tests/IntegrationTests/Events/RepositoryManagerTests.cs#L24-L62\r\n\r\n","author":{"url":"https://github.com/neuroKip","@type":"Person","name":"neuroKip"},"datePublished":"2017-10-11T14:44:37Z","url":"https://github.com/github-for-unity/Unity/issues/356"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:a615c017-3366-e554-ba50-a78135ca3da1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9752:38C5CF:5ADB01:772AD9:6B00CD31
html-safe-nonce5f2a9cb7564fc8e6c23d2f54674ce65768a6f3169897c2544d42c28b44cfc750
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzUyOjM4QzVDRjo1QURCMDE6NzcyQUQ5OjZCMDBDRDMxIiwidmlzaXRvcl9pZCI6IjMwOTc0NzExNjIzMDE1OTkwMjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaca2ffd1e6bb1195e2cd7ca7e4ace2e0f10324e9ff73935ca28ddddf628ca063ee
hovercard-subject-tagrepository:94770860
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/github-for-unity/Unity/issues/356
twitter:imagehttps://opengraph.githubassets.com/c304a76c888259a02bd524603e459010beee41d3e05d9274f7bdc09ec8c21ead/github-for-unity/Unity
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c304a76c888259a02bd524603e459010beee41d3e05d9274f7bdc09ec8c21ead/github-for-unity/Unity
og:image:altGitHub for Unity. Contribute to github-for-unity/Unity development by creating an account on GitHub.
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None85bbdfe2b6ba16e234513bc6ceff5d848ef8449820c900692a2b4e67061931e5
turbo-cache-controlno-cache
go-importgithub.com/github-for-unity/Unity git https://github.com/github-for-unity/Unity.git
octolytics-dimension-user_id28719038
octolytics-dimension-user_logingithub-for-unity
octolytics-dimension-repository_id94770860
octolytics-dimension-repository_nwogithub-for-unity/Unity
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id94770860
octolytics-dimension-repository_network_root_nwogithub-for-unity/Unity
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4943239a6d2c591325dad6e5c313e1cafda877f6
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/github-for-unity/Unity/issues/356#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub-for-unity%2FUnity%2Fissues%2F356
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub-for-unity%2FUnity%2Fissues%2F356
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=github-for-unity%2FUnity
Reloadhttps://github.com/github-for-unity/Unity/issues/356
Reloadhttps://github.com/github-for-unity/Unity/issues/356
Reloadhttps://github.com/github-for-unity/Unity/issues/356
https://github.com/github-for-unity/Unity
Feature: Add functionality to discard changeshttps://github.com/github-for-unity/Unity/issues/356#top
enhancementhttps://github.com/github-for-unity/Unity/issues?q=state%3Aopen%20label%3A%22enhancement%22
hacktoberfesthttps://github.com/github-for-unity/Unity/issues?q=state%3Aopen%20label%3A%22hacktoberfest%22
https://github.com/neuroKip
neuroKiphttps://github.com/neuroKip
on Oct 11, 2017https://github.com/github-for-unity/Unity/issues/356#issue-264614871
https://user-images.githubusercontent.com/310137/31720974-5b9b31a4-b418-11e7-89cc-d04c49f5e26b.png
#356https://github.com/github-for-unity/Unity/issues/356
https://github.com/github-for-unity/Unity/blob/master/src/GitHub.Api/Git/Tasks/GitAddTask.cshttps://github.com/github-for-unity/Unity/blob/master/src/GitHub.Api/Git/Tasks/GitAddTask.cs
https://github.com/github-for-unity/Unity/blob/master/src/GitHub.Api/Git/GitClient.cs#L371-393https://github.com/github-for-unity/Unity/blob/master/src/GitHub.Api/Git/GitClient.cs#L371-393
https://github.com/github-for-unity/Unity/blob/master/src/tests/IntegrationTests/Events/RepositoryManagerTests.cshttps://github.com/github-for-unity/Unity/blob/master/src/tests/IntegrationTests/Events/RepositoryManagerTests.cs
https://github.com/github-for-unity/Unity/blob/master/src/tests/IntegrationTests/Events/RepositoryManagerTests.cs#L24-L62https://github.com/github-for-unity/Unity/blob/master/src/tests/IntegrationTests/Events/RepositoryManagerTests.cs#L24-L62
neuroKiphttps://github.com/neuroKip
on Oct 11, 2017https://github.com/github-for-unity/Unity/issues/356#event-1288367322
https://github.com/StanleyGoldman
StanleyGoldmanhttps://github.com/StanleyGoldman
on Oct 11, 2017https://github.com/github-for-unity/Unity/issues/356#issuecomment-335840805
@shanahttps://github.com/shana
#151https://github.com/github-for-unity/Unity/pull/151
https://github.com/neuroKip
neuroKiphttps://github.com/neuroKip
on Oct 11, 2017https://github.com/github-for-unity/Unity/issues/356#issuecomment-335843325
@StanleyGoldmanhttps://github.com/StanleyGoldman
StanleyGoldmanhttps://github.com/StanleyGoldman
on Oct 11, 2017https://github.com/github-for-unity/Unity/issues/356#event-1288617211
StanleyGoldmanhttps://github.com/StanleyGoldman
StanleyGoldmanhttps://github.com/StanleyGoldman
neuroKiphttps://github.com/neuroKip
StanleyGoldmanhttps://github.com/StanleyGoldman
on Oct 11, 2017https://github.com/github-for-unity/Unity/issues/356#event-1288621047
StanleyGoldmanhttps://github.com/StanleyGoldman
enhancementhttps://github.com/github-for-unity/Unity/issues?q=state%3Aopen%20label%3A%22enhancement%22
hacktoberfesthttps://github.com/github-for-unity/Unity/issues?q=state%3Aopen%20label%3A%22hacktoberfest%22
on Oct 11, 2017https://github.com/github-for-unity/Unity/issues/356#event-1288622041
https://github.com/StanleyGoldman
StanleyGoldmanhttps://github.com/StanleyGoldman
on Oct 11, 2017https://github.com/github-for-unity/Unity/issues/356#issuecomment-335880134
https://github.com/StanleyGoldman
StanleyGoldmanhttps://github.com/StanleyGoldman
on Oct 13, 2017https://github.com/github-for-unity/Unity/issues/356#issuecomment-336498163
StanleyGoldmanhttps://github.com/StanleyGoldman
neuroKiphttps://github.com/neuroKip
on Oct 13, 2017https://github.com/github-for-unity/Unity/issues/356#event-1292587897
https://github.com/neuroKip
neuroKiphttps://github.com/neuroKip
on Oct 16, 2017https://github.com/github-for-unity/Unity/issues/356#issuecomment-336848377
neuroKiphttps://github.com/neuroKip
completedhttps://github.com/github-for-unity/Unity/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 16, 2017https://github.com/github-for-unity/Unity/issues/356#event-1294561711
neuroKiphttps://github.com/neuroKip
on Oct 16, 2017https://github.com/github-for-unity/Unity/issues/356#event-1294561853
https://github.com/neuroKip
neuroKiphttps://github.com/neuroKip
on Oct 16, 2017https://github.com/github-for-unity/Unity/issues/356#issuecomment-336886713
#366https://github.com/github-for-unity/Unity/pull/366
https://github.com/neuroKip
neuroKiphttps://github.com/neuroKip
on Oct 20, 2017https://github.com/github-for-unity/Unity/issues/356#issuecomment-338243995
https://github.com/StanleyGoldman
StanleyGoldmanhttps://github.com/StanleyGoldman
on Nov 1, 2017https://github.com/github-for-unity/Unity/issues/356#issuecomment-341249696
#370https://github.com/github-for-unity/Unity/pull/370
@shanahttps://github.com/shana
shanahttps://github.com/shana
completedhttps://github.com/github-for-unity/Unity/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#533https://github.com/github-for-unity/Unity/pull/533
on Mar 7, 2018https://github.com/github-for-unity/Unity/issues/356#event-1508678512
shanahttps://github.com/shana
on Mar 7, 2018https://github.com/github-for-unity/Unity/issues/356#event-1508679466
https://github.com/shana
shanahttps://github.com/shana
on Mar 7, 2018https://github.com/github-for-unity/Unity/issues/356#issuecomment-371114109
#533https://github.com/github-for-unity/Unity/pull/533
shanahttps://github.com/shana
completedhttps://github.com/github-for-unity/Unity/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 19, 2022https://github.com/github-for-unity/Unity/issues/356#event-7624091954
Sign up for freehttps://github.com/signup?return_to=https://github.com/github-for-unity/Unity/issues/356
Sign in to commenthttps://github.com/login?return_to=https://github.com/github-for-unity/Unity/issues/356
enhancementhttps://github.com/github-for-unity/Unity/issues?q=state%3Aopen%20label%3A%22enhancement%22
hacktoberfesthttps://github.com/github-for-unity/Unity/issues?q=state%3Aopen%20label%3A%22hacktoberfest%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.