Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I edit two files then make one commit using GitHub Web-based editor?

GitHub has the nice feature of Web-based file editing. However, it seems that after editing one file I have to commit the changes for this file before continuing. Is there a way I can edit two or more files then make one commit for all the changes of them?

I think this would be better since too many unnecessary commits are annoying.

like image 578
shengbinmeng Avatar asked Jul 23 '13 16:07

shengbinmeng


People also ask

Can you edit commits on GitHub?

Right-click on the most recent commit and select Amend commit. Click the Summary field to modify the commit message. Optionally, you can modify or add information about the commit in the Description field. Select any uncommitted changes that you would like to add to the commit.


2 Answers

There is a web-based workaround:

  1. Create a temporary branch, switch to it;
  2. Edit multiple files, commit each file separately;
  3. Make pull request;
  4. Under Merge pull request button, choose Squash and merge (if the repo allows it), then confirm merge;
  5. Delete temporary branch.

I use this method on a PC which I don't want to install git on.

like image 52
Victor Istomin Avatar answered Sep 21 '22 06:09

Victor Istomin


Yes there is a way to edit 2 files, when you've already edited your first file in the web browser view of GitHub. It's based on the instructions here:

https://webapps.stackexchange.com/questions/95940/how-can-i-change-multiple-files-and-submit-them-in-one-pull-request-on-github

The summary and clarified steps are:

  1. Edit your first file, by clicking the Edit icon in another user's repository. Save this edit in your first commit. GitHub will automatically create a new branch/fork for you, like "patch-1".
  2. Do not create a Pull Request yet.
  3. [This part is the most difficult, because it's not obvious] Go to the list of repositories in your profile, at github.com ➔ click icon at top-right ➔ Your Repositories. Then go to the forked repository that you've just made, and switch to the "patch-1" branch.
  4. Continue making changes to another file, and commit it to your "patch-1" branch. When you are done, click the "Pull Requests" tab near the top, then click Compare & Pull Request or Create Pull Request. You should see your 2 commits in this Pull Request.
  5. If you don't see a "Create Pull Request" button, open a URL like this in your web browser: https://github.com/TargetPerson/TargetGitRepo/compare/master...MyGithubUsername:patch-1
  6. This will show a view to compare your changes to the original target branch in the other user's repository. Then press the Create Pull Request button.
like image 29
Mr-IDE Avatar answered Sep 24 '22 06:09

Mr-IDE