Tag Archives: git

Two New Commands

I enjoy learning new things. When I do, I’ll try to write them down in case others may perhaps also find them useful. If nothing else, the notes may help me when I’m wondering, “How did this get solved last time?”

My team at work is in the process of switch from Subversion to Git and GitHub. Git is new ground for many of us, as is the bash prompt (On Windows, Git includes a full-fledged bash prompt). Doing some troubleshooting today, I learned some new new things about both tools.

Pretty git logs

The first was a new Git command:
 git log --graph --oneline

This creates a wonderful ASCII-art timeline, showing all your commits and showing how files have been merged into the project.

For a project of any complexity, this simple visualization is wonderful for understanding the flow of changes and merges by multiple developers. Check out this snippet from PhantomCSS for example:

[email protected] MINGW64 ~/test
$ git log --graph --oneline
* 20db940 0.10.4
* a482cc3 Merge pull request #127 from raveclassic/master
| * bbbaa22 fixed TypeError when calling phantomcss.compareAll() #68
* | e44196e Merge pull request #125 from shadowfiles/extension-settings
|\ \
| * | 28a397f Added option to specify the suffix names of screenshot types.
| |/
* | d8479cf Merge pull request #124 from renanborgez/patch-1
|\ \
| |/
| * 4b0913f Update README.md
* 84945e5 0.10.2


Commit 4b0913f (near the bottom) updates the README.md and is then meged back in commit d8479cf.  Meanwhile, a separate developer is adding new functionality in commit 28a397f, merges two pull requests in commits e44196e and bbbaa22 before everything comes back together in a482cc3

It’s a bit cryptic at first, but much easier to fathom than the straight up git log.

The same format also appears, in a non-text based format, in the gitk tool.

A new (to me) bash command

The other new command was from bash. I’ve known for a while that your command line history is stored in ~/.bash_history, but I didn’t know what it was good for aside from presumably powering the up-arrow / down arrow line-at-a-time history.

Turns out that the history command also displays your command line history, and it’s waaaaay more convenient than typing
more < ~/.bash_history
As a bonus, if you have multiple terminals open, this command is guaranteed to show the history for the current window rather than the one most recently closed.

Geek Humor

One of my co-workers retired back in the Spring, but still stops by to visit on occasion. He understood the importance of software source control, but had a few struggles with it. As he was leaving after his most recent visit, we had this brief exchange

  • Co-Worker: You know, I left on March 15 and haven’t had any tree conflicts since then.
  • Me: That’s great! No branches falling in the back yard?
  • Co-Worker: Well… at least, they weren’t trying to merge.

It’s difficult to get much geekier than when you’re making source control puns.

git error: Permission to user-B/repo.git denied to user-A

I have two GitHub accounts: UserA and UserB. Over time I’ve been switching to working with UserB, but the switchover was a bit difficult.

I created a test repository on GitHub at https://github.com/UserB/test

On the local system, from the command prompt

cd \git
git clone https:[email protected]/UserB/test
cd test
# make some changes to README.md, add a new foo.txt
git add *
git commit -m "Banana!" # In real life, you'll probably want a more useful comment.

And that’s where the train went off the rails…

C:\git\test>git push
remote: Permission to UserB/test.git denied to UserA.
fatal: unable to access 'https:[email protected]/UserB/test/': The requested URL returned error: 403

So git’s saying that even though I expressly got this as UserB, it still thinks I’m UserA

Google came back with lots of stuff about making sure you have the right SSH key (apparently the cool kids do everything over SSH).

A few search results make reference to the Windows Credential Manager. Apparently the Windows version of Git hooks into that somehow. What’s the Windows Credential Manager? Well, from the name, it sounds like something that might be used for storing userids and passwords.

OK, so how do I invoke it? Dunno. Let’s try the search box on the START menu. Aha! Two entries. One for “Credential Manager” and one for “Manage Windows Credentials.”

So let’s try the first one. Hey! This looks promising:

About halfway down the list, there’s one labeled “git:https://github.com” Let’s expand that.

Oh, looky there! Username and password.

Now what I did was to remove the entry and then push again. I was prompted to enter a userid and password. I still had to type the password at the command prompt, but IT STUCK.

C:\git\test>git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 304 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/UserB/test
5e74c47..cf2ca13 master -> master

I probably could have clicked “Edit” and changed the userid and password, and just kept going, but I didn’t notice the “Edit” right away.

It looks as though you might actually be able to have multiple entries for git:https://github.com, but I haven’t tried that yet.

(Public domain photo from PublicDomainPictures.net)