By appending .patch to the commit URL, a commit can easily be downloaded as patch. (Details)
By appending .patch to the pull request URL (e.g. https://github.com/kuali/rice/pull/12.patch ), a pull request can easily be downloaded as patch. (Details)
To nuke the last commit:
git reset --hard HEAD~1
To edit the last commit:
git reset --soft HEAD~1
Using the "edit" option of the interactive rebase allows additional modification to that commit. Use
git rebase -i HEAD~3 where the number in HEAD~3 indicates how many commits back the interactive rebasing should go. See Fixing a commit via interactive rebase edit for detailed step-by-step example.
It is recommended to do changes in a fix branch (normally named after the JIRA id). This makes it easier to work on multiple issues at the same time.
For example you are working on feature A, commit that to master as feature-A-commit, and create a pull request. While your pull request is outstanding your personal rice repository is one commit ahead of kuali:master. If you were to branch your master then feature-A-commit is included on that branch and that commit will be included in any further pull request that is created. In essence your feature B work would have feature-A-commit as well as feature-B-commit which is not what we want. You'd manually would have to remove the feature-A-commit before creating the pull request for feature B.
git ls-files -m -d "*.iml" ".idea\*.xml" | tr '\n' '\ ' | tr '\r' '\ ' | xargs git update-index --assume-unchanged
Note, some of these commands need to be done in a shell, so on windows use Git Bash.
Locate the commit at which the tag should be placed. For releases it's the commit that changes the version number to the released version e.g. https://github.com/kuali/rice/commit/076c861a35c2120e55de06b55e9030ce7d5584ec .
# update your local tags with kuali/rice repo git fetch --tags upstream # switch to the point at which the tag should be created git checkout 076c861a35c2120e55de06b55e9030ce7d5584ec # create the tag with the date of the original commit GIT_COMMITTER_DATE="$(git show --format=%aD | head -1)" git tag rice-1.0.6 # switch back to master branch otherwise a new branch (rice-1.0.6) will be created along with the tag git checkout master # push changes to kuali/rice repo git push --tags upstream
# delete the tag git tag -d rice-1.0.8 # push changes to kuali/rice repo git push upstream :refs/tags/rice-1.0.8
If you want prevent yourself from pushing changes back to a repo that you have cloned you can use the following command
git remote set-url --push origin DISALLOWED
which will cause and error on push.
git remote -v will look like:
origin DISALLOWED (push)
To discard everything and start anew on a branch run the following commands:
git fetch upstream git reset --hard upstream/<branch-name>