Last active
September 14, 2019 07:23
-
-
Save constrict0r/174dfdbe68428db74c0f9abb7fdc4359 to your computer and use it in GitHub Desktop.
Git branch-rebase-merge process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Git new branch-rebase-merge process. | |
| # On this snippet we changed the name of the folder | |
| # license to license-repo. | |
| # Get last changes and create a new branch. | |
| git pull origin master | |
| git checkout -b license-repo | |
| # Here we make changes to the repository and add our commits. | |
| # Rename folder license to license-repo. | |
| git rm license/mit.inc | |
| git add license-repo/mit.inc | |
| git commit -m "Renamed folder license to license-repo for legibility" | |
| # Show commits. | |
| git log --graph --decorate --pretty=oneline --abbrev-commit | |
| # Shows: | |
| # * e3684b3 (HEAD -> license-repo) Updated file layout | |
| # * 30ed677 Rename license to license-repo for legibility | |
| # * 7854b7e (origin/master, origin/HEAD, master) Added all parts | |
| # Open the editor to select the commits to squash (squash all in one). | |
| git rebase -i HEAD~2 | |
| # When the editor is open, change 'pick' to 's' (squash) on the second commit message. | |
| # The editor will show something like: | |
| # pick 30ed677 Rename license to license-repo for legibility | |
| # pick e3684b3 Updated file layout | |
| # Rebase 7854b7e..30ed677 onto 7854b7e (1 command) | |
| # | |
| # Commands: | |
| # p, pick = use commit | |
| # r, reword = use commit, but edit the commit message | |
| # e, edit = use commit, but stop for amending | |
| # s, squash = use commit, but meld into previous commit | |
| # Change: | |
| # pick 30ed677 Rename license to license-repo for legibility | |
| # pick e3684b3 Updated file layout | |
| # To: | |
| # pick 30ed677 Rename license to license-repo for legibility | |
| # s e3684b3 Updated file layout | |
| # Save the file and close the editor. | |
| # Show new commits history. | |
| git log --graph --decorate --pretty=oneline --abbrev-commit | |
| # Shows: | |
| # * e5126bd (HEAD -> license-repo) Rename license to license-repo for legibility | |
| # * 7854b7e (origin/master, origin/HEAD, master) Added all parts | |
| # Upload changes. | |
| git push origin license-repo | |
| # Rebase process. | |
| git checkout master | |
| git pull origin master | |
| git checkout license-repo | |
| git rebase master | |
| # If new repository this could show the warning: Current branch license-repo is up to date. | |
| # Upload changes. | |
| git push origin license-repo --force | |
| # If new repository this could show: Everything up-to-date. | |
| # Merge process. | |
| git checkout master | |
| git merge license-repo | |
| # Shows something like: | |
| # Updating 7854b7e..e5126bd | |
| # Fast-forward | |
| # README.md | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------- | |
| # {license => license-repo}/mit.inc | 0 | |
| # 2 files changed, 73 insertions(+), 24 deletions(-) | |
| # rename {license => license-repo}/mit.inc (100%) | |
| # Upload changes. | |
| git push origin master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment