can you rename a git commit message?

This is the place for queries that don't fit in any of the other categories.

can you rename a git commit message?

Postby metulburr » Wed May 21, 2014 2:52 pm

Can you fix typos in a commit message?

An example would be:
Code: Select all
metulburr@ubuntu ~/repos/floodit $ git log --pretty=format:"%h - %an, %ar : %s"
657e11e - metulburr, 2 days ago : pushed latest
19ae402 - metulburr, 3 days ago : polished options menu
dc60c79 - metulburr, 3 days ago : added display options
4a48bbf - metulburr, 3 days ago : working on fullscreen toggle option midgame
9a00b40 - metulburr, 5 days ago : Merge https://github.com/metulburr/FloodIt
f448755 - metulburr, 5 days ago : added rounded buttons
9f0b45d - metulburr, 5 days ago : Update README.md
0670d7d - metulburr, 5 days ago : Update README.md
916ef28 - metulburr, 8 days ago : fixed typo
709547c - metulburr, 8 days ago : Merge https://github.com/metulburr/FloodIt
46894cf - metulburr, 8 days ago : exe build 20140513, fixed lost counter increment bug when winning
63458e8 - metulburr, 9 days ago : Update README.md
2300c70 - metulburr, 9 days ago : Create README.md
bb9abe5 - metulburr, 9 days ago : exe build 20140512
8132ac4 - metulburr, 9 days ago : added win score
7baba69 - metulburr, 10 days ago : added points
dc031f4 - metulburr, 10 days ago : added board background
3081cdd - metulburr, 10 days ago : fixed big regarding last turn and last color stops game win
194515b - metulburr, 10 days ago : added game logic, fine tuned game
e229dbb - metulburr, 11 days ago : pushed latest
bd54010 - metulburr, 12 days ago : init push
metulburr@ubuntu ~/repos/floodit $


i typo on line:
Code: Select all
3081cdd - metulburr, 10 days ago : fixed big regarding last turn and last color stops game win

where i should of typed "bug" instead of "big"

Is there a clean way to fix this...without rewriting history and making additional commits?
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1321
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: can you rename a git commit message?

Postby 7stud » Thu May 22, 2014 4:30 am

I just did it recently, but it was for the last commit and it hadn't been pushed yet. It takes more work if it's been pushed. If it's been pushed, you really shouldn't do it--however if you are the sole person on the project have at it. Plenty of directions on the google:

http://www.rocketmill.co.uk/how-to-edit ... age-in-git
7stud
 
Posts: 85
Joined: Wed Apr 02, 2014 2:36 am

Re: can you rename a git commit message?

Postby metulburr » Thu May 22, 2014 10:34 am

I am trying to edit the last message on a test repo

Code: Select all
metulburr@ubuntu ~/repos/git-testing  $ git commit --amend
[master 31b1674] some wrongful msg that i want to replace
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test.txt

Code: Select all
metulburr@ubuntu ~/repos/git-testing $ git push origin master
Username for 'https://github.com': metulburr
Password for 'https://metulburr@github.com':
To https://github.com/metulburr/git-testing.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/metulburr/git-testing.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Code: Select all
metulburr@ubuntu ~/repos/git-testing  $ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://github.com': metulburr
Password for 'https://metulburr@github.com':
To https://github.com/metulburr/git-testing.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/metulburr/git-testing.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Code: Select all
metulburr@ubuntu ~/repos/git-testing  $ git config --global push.default simple

Code: Select all
metulburr@ubuntu ~/repos/git-testing $ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

Code: Select all
metulburr@ubuntu ~/repos/git-testing  $ git push --set-upstream origin master
Username for 'https://github.com': metulburr
Password for 'https://metulburr@github.com':
To https://github.com/metulburr/git-testing.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/metulburr/git-testing.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


lol apparently i have no idea what i am doing. https://github.com/metulburr/git-testing/commits/master


EDIT:
i tried again and this time it pushed the old message that was staged?

Code: Select all
metulburr@ubuntu ~/repos/git-testing $ touch test2.txt
metulburr@ubuntu ~/repos/git-testing $ git add *
metulburr@ubuntu ~/repos/git-testing $ git commit -m "another bullshit msg"
[master 333aaf2] another bullshit msg
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test2.txt
metulburr@ubuntu ~/repos/git-testing $ git status
On branch master
nothing to commit, working directory clean
metulburr@ubuntu ~/repos/git-testing $ git commit --amend
[master c100b08] another bullshit msg
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test2.txt
metulburr@ubuntu ~/repos/git-testing $ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

metulburr@ubuntu ~/repos/git-testing  $ git push --set-upstream origin master
Username for 'https://github.com': metulburr
Password for 'https://metulburr@github.com':
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 282 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To https://github.com/metulburr/git-testing.git
   772a945..c100b08  master -> master
Branch master set up to track remote branch master from origin.
metulburr@ubuntu ~/repos/git-testing $


Im reading through pro git, and finding that git is even more complex than what i initially thought it was.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1321
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 3 guests