You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you fix a bug or create a new feature – do it in a separate branch!
git clone git://github.com/jimbrig/repo.git
cd repo
git checkout -b bugfix_branch
Before merging or starting a PR, consider creating a patch!
Creating a patch
First, check the log of the branch:
git-log --pretty=oneline -3
Here's how to create a patch:
git format-patch master --stdout > fix_bug.patch
This will create a new file fix_bug.patch with all changes from the current (bugfix_branch) against master. Normally, git would create a separate patch file for each commit, but that’s not what we want. All we need is a single patch file.
Apply Patch
First, take a look at what changes are in the patch. You can do this easily with git apply
git apply --stat fix_bug.patch
Note that this command does not apply the patch, but only shows you the stats about what it’ll do. After peeking into the patch file with your favorite editor, you can see what the actual changes are.
Next, you’re interested in how troublesome the patch is going to be. Git allows you to test the patch before you actually apply it.
git apply --check fix_bug.patch
To apply the patch, I’ll use git am instead of git apply.
The reason for this is that git am allows you to sign off an applied patch.
This may be useful for later reference.
git am --signoff < fix_empty_poster.patch
Applying: Added specs to test empty poster URL behaviour
Applying: Added poster URL as part of cli output
You then use git merge to update any branch on the upstream repository:
$ git merge upstream/dev
Sync a remote fork on Github
Open your fork on GitHub.
Click on Pull Requests.
Click on New Pull Request. By default, GitHub will compare the original with your fork, and there shouldn’t be anything to compare if you didn’t make any changes.
Click on Try switching the base. Now GitHub will compare your fork with the original, and you should see all the latest changes.
Click on Click to create a pull request for this comparison and assign a predictable name to your pull request (e.g., Update from original).
Click on Send pull request.
Scroll down and click Merge pull request and finally Confirm merge. If your fork didn’t have any changes, you will be able to merge it automatically.
2fa
Using two factor authentication? Then use the following so you're not adding in your auth token each time you want to push your code.
# Checkout the desired branch
git checkout <branch># Undo the desired commit
git revert <commit># Update the remote with the undo of the code
git push origin <branch>
Rather than use the last part I unstaged the changes in VSCode which I think did the same thing.
Show .gitconfig details
git config --list --show-origin
If you want to rename a branch while pointed to any branch, do:
git branch -m <oldname><newname>
If you want to rename the current branch, you can do:
git branch -m <newname>
A way to remember this, is -m is for "move" (or mv), which is how you rename files.