git | merge-commits and pull-requests

Key question — Q1: which commit would have multiple parents?

— scenario 1a:

  1. Suppose your feature branch brA has a commit hash1 at its tip; and master branch has tip at hashJJ, which is the parent of hash1
  2. Then you decide to simply q[ git merge brA ] into master

In this simple scenario, your merge is a fast-forward merge. The updated master would now show hash1 at the tip, whose only parent is hashJJ.

A1: No commit would have multiple parents. Simple result. This is the default behavior of git-merge.

Note this scenario is similar to

However, github or bit-bucket pull-request flow don’t support it exactly.

— scenario 1b:

Instead of simple git-merge, what about pull request? A pull-request uses q[ git merge –no-ff brA ] which (I think) unconditionally creates a merge-commit hashMM on maser.

A1: now hashMM has two parents. In fact, git-log shows hashMM as a “Merge” with two parent commits.

Result is unnecessarily complex. Therefore, in such simple scenarios, it’s better to use git-merge rather than pull request. explains the details.

— Scenario 2: What if ( master’s tip ) hashJJ is Not parent of hash1?

Now maser and brA have diverged. I think you can’t avoid a merge commit hashMM.

A1: hashMM

— Scenario 3: continue from Scenario 1b or Scenario2.

3. Then you commit on brA again , creating hash2.

Q: What’s the parent node of hash2?
A: I think git actually shows hash1 as the parent, not hashMM !

Q: is hashMM on brA at all?
A: I don’t think so but some graphical tools might show hashMM as a commit on brA.

I think now master branch shows  hashMM having two parents (hash1+hashMM), and brA shows hash1 -> hash2.

I guess that if after the 3-way-merge, you immediately re-create (or reset) brA from master, then hash2’s parent would be hashMM.


  • direct-commit on master is implicitly fast-forward, but merge can be fast-forward or non-fast-forward.
  • fast-forward merge can be replaced by a rebase as in Scenario 1a. Result is same as direct-commit.
  • fast-forward merge-commit (Scenario 1b) and 3way merge (Scenario 2) both create a merge-commit.
  • git-pull includes a git-merge without –no-ff

gradle: dependency-jar refresh, cache, Intellij integration..

$HOME/.gradle holds all the jars from all previous downloads.

[1] When you turn on debug, you can see the actual download : gradle build –debug.

[2] Note IDE java editor can use version 123 of a jar for syntax check, but the command line compilation can use version 124 of the jar. This is very common in all IDEs.

When I make a change to a gradle config,

  • Intellij prompts for gradle import. This seems to be unnecessary re-download of all jars — very slow.
  • Therefore, I ignore the import. I think as a result, Intellj java editor [2] would still use the previous jar version as the old gradle config is in effect. I live with this because my focus is on the compilation.
  • For compilation, I use the grade “build” action (probably similar to command line build). Very fast but why? Because only one dependency jar is refreshed [3]
  • Gary used debug build [1] to prove that this triggers a re-download of specific jars iFF you delete the jars from $HOME/.gradle/caches/modules-2/files-2.1

[3] For a given dependency jar, “refresh” means download a new version as specified in a modified gradle config.

— in console, run

gradle build #there should be a ./build.gradle file

intellij=cleaner than eclipse !

intellij (the community version) is much cleaner than eclipse, and no less rich in features.

On a new job, My choice of java ide is based on
1) other developers in the team, as I need their support

2) online community support — as most questions are usually answered there
I think eclipse beats intellij

3) longevity — I hate to learn a java ide and lose the investment when it loses relevance.
I think eclipse beats intellij, due to open-source

)other factors include “clean”

The most popular tools are often vastly inferior for me. Other examples:
* my g++ install in strawberryPerl is better than all the windows g++ installs esp. msvs
* my git-bash + strawberryPerl is a better IDE than all the fancy GUI tools
* wordpress beats hands down
* wordpad is a far simpler rich text editor than msword or browsers or mark-down editors

debugger stepping into library

I often need my debugger to step into library source code.

Easy in java:

c++ is harder. I need to find more details.

  • in EclipseCDT, STL source code is available to IDE ( probably because class templates are usually in the form of header files), and debugger is able to step through it, but not so well.

Overall, I feel debugger support is significantly better in VM-based languages than c++, even though debugger was invented before these new languages.

I guess the VM or the “interpreter” can serve as an “interceptor” between debugger and target application. The interceptor can receive debugger commands and suspend execution of the target application.

git | reword historical commit msg

Warning — may not work if there’s a recent merge-in on your branch

Find the target commit and its immediate parent commit.

git rebase -i the.parent.commit

First commit in the list would be your target commit. Use ‘r’ for the target commit and don’t change other commits. You will land in vim to edit the original bad commit msg. Once you save and quit vim, the rebase will complete, usually without error.

Now you can reword subsequent commit messages.

git | diff | make file6 appear before file2

The pain — a big commit touches on too many files, 3 of them major changes, while 5 files have cosmetic changes. In git-diff or git-difftool, I want to focus on the 3 major files.

Some developers would want to split the big commit into a “major” and a “cosmetic” commit, but one of the snapshots would be half-cooked and unusable. In such a case, the commit comment would warn “This commit is part of a bigger change. Please do not build this commit alone”.

As an alternative we can make the 3 major files show up first (or last) in diff. You can put the content below in src/diffOrder.txt and use it as instructed. All unspecified files would show up in natural order.

# git diff -O src/diffOrder.txt
# check EACH line below to ensure unix line ending, even if entire file is unix-style.
# wildcards are needed below.


git | tag | (commit^tagger)date

A git tag can have two dates (and author, and msg)

  • the tag-creation date i.e. tagger date (and tagger name, tagger msg)
  • date (and author and msg) of the commit referenced by the tag
    • this is always earlier than the tagger date

A lightweight tag has no tagger date (or tagger name or msg)

When you run ‘git show myTag’ you will see the tagger date ( and tagger name + msg) only if the tag is an annotated (a.k.a heavyweight) tag.git

— sort by date

git tag –sort=-taggerdate # may not work well for lightweight tags

git log --tags --simplify-by-decoration --pretty="format:%ci | %d" |sort -r

git commit – -am # risky

Consider the harmless-looking command git commit –am

Most of the time, I rely on this command as a safe way to amend commit message without touching the original files in the commit.

However, if there’s further changes on file1 in staging, then this command would silently introduce this change into the commit. Once you finalize the commit message and save it, this change inadvertently becomes part of the commit !

error stack trace: j^c++

Without stack trace, silent crashes are practically intractable.

In my java and python /career/ (I think c# as well) , exceptions always generate a console stack trace. The only time it didn’t happen was a Barclays JNI library written in c++..

In c++, getting the stack trace is harder.

  • when I used the ETSFlowAsert() construct I get a barely usable stack trace, with function names, without line numbers
  • [[safeC++]] described a technique to generate a simple stack trace with some line numbers but I have never tried it
  • the standard assert() macro doesn’t generate stack trace
  • In RTS and mvea, memory access errors lead to seg-fault and core dump. In these contexts we are lucky because the runtime environment (host OS, standard library, seg-fault signal handler ..) cooperate to dump some raw data into the core file, but it’s not as reliable as the JVM runtime … Here are some of the obstacles:
    • core files may be suppressed
    • To actually make out this information, we need gdb + a debug build of the binary with debug symbols.
    • it can take half an hour to load the debug symbols
    • My blogpost %%first core dump gdb session describes how much trouble and time is involved to see the function names in the stack trace.


git | beyondCompare

— bcomp advantage over git-diff
bcomp shows byte count in new vs old versions… can detect intrafile cut-paste

— based on

git config --global diff.tool bc
git config --global difftool.bc.path /c/Progra~1/BeyondCompare4/BComp.exe
git config --global difftool.prompt false

The above sets up git-difftool but how about git-diff? I feel one of the two is sufficient.

git config --global merge.tool bc
git config --global mergetool.bc.path /c/Progra~1/BeyondCompare4/BComp.exe

— no integration with git-diff?
Think again. If your git-diff always uses a GUI, then you can’t get the console UI which is frequently valuable. Therefore, it’s a good thing that you can’t modify git-diff. worked for me, including a 3-way merge GUI —

git mergetool feature/my_br6 origin/feature/my_br6 --


git | list all(and only)commits from branching point to a descendant commit

Background — Suppose you made 3 commits on your feature branch name “parix”, but meanwhile, someone added 4 commits in master branch. Therefore there is now a divergence in the commit history graph.

Often times you need to visualize the divergence. You need to exactly what 3 commits are on your branch after the common ancestor.

git log master..pairx # listing the 3 additional commits in pairx branch, right after the common ancestor i.e. the branching point

git log pairx..master # to show those 4 commits.

git | merge conflict #personal tips

I prefer cherry-pick.

Often the merge/rebase/cherry-pick/stash-pop operation would silently put some of the changes in _staging_, therefore git-diff would fail to show them. I have to use git-diff-HEAD instead:(

–If you have no choice then here’s the standard procedure

  1. git rebase master
  2. you get a merge conflict and file1 now contains <<<< ===
  3. vi file1 # to remove the bad stuff
  4. git add file1 # on the unnamed branch
  5. # no commit needed
  6. git rebase –continue # will bring you back to your feature branch


simple Windows c++(python)set-up #Intellj is better4java

See also easiest windows GCC installer #c++17

Git-Bash + StrawberryPerl is the best combo for me on Windows. I put g++ commands in bash scripts to automate my GCC build and test. Note my typical project has at most 20 source files.

Git-Bash + StrawberryPerl + Notepad++ is better for me than any c++ IDE like Eclipse CDT (4 installations), Bloodshed (4), CodeBlocks (1), NetBeans…

  • I don’t need code completion..
  • I don’t need jump into a type definition.
  • I don’t need my debugger to be visual. StrawberryPerl includes gdb
  • I use Notepad++ for text search across hundreds of files
  • I use Notepad++ for search/replace
  • I use diff and git-diff to see code changes
  • I used github for version history

I’m such a die-hard fan of command line that the only GUI development tool I use is notepad++ and it’s optional. Since 2015, my Linux c++ code editor has been VIM, which I used on large codebases consisting of 1000+ source files.

For about 2 years EclipseCDT was my default choice, then the simpler Bloodshed became my default choice as it is simpler than EclipseCDT. However they are still over-complicated. I didn’t have a favorite until 2017, when I discovered Notepad++/Git-Bash/StrawberryPerl

Q: why do I use Eclipse for Java but not for c++?
A: Eclipse is more problematic, more messy for c++ than for java. The benefits (convenience, automation..) is offset by the high TCO (total cost of ownership). For example, java debugger, java code navigation, java renaming/refactor all work better than c++.

Q: how about MS VisualStudio?
A: I managed a large c++ codebase on MSVS 2015 in 2015-2016, about a year+. Too complicated, worse than MSVS for c#. I would never prefer it over my command line set-up, if given a choice.

By the way, Git-Bash works well with a standard python installation, but I do recommend the tweak at

easiest MSWindows G++ installer #c++17 is an easy installer for Perl and it bundles GCC. I was able to compile in c++17 mode:

g++ -std=c++17 my.cpp

My experiences with cygwin and mingw were both horrible.

  1. cygwin — too bulky and unnecessary, and affected my existing Windows features. I tried sygwin once many years ago and quickly concluded that it was designed for people unlike me. Those people would have only positive experiences about cygwin that I don’t share.
  2. mingw — supposed to be minimalist, but I tried installing it at least 3 (up to 6) times and always painful.

In contrast, I installed strawberryPerl about 3 times and once on a friend’s laptop … always quick and easy. No tweaking required. GCC + gdb works out of the box.

gdb to show c++thread wait`for mutex+condVar shows gdb works out of the box.

Through almost 10 installations of GCC on various windows laptops, I have come to the obvious conclusion.

git-stash survival guide

Two simple steps:

git stash #no args

# Now git diff will no longer show the uncommitted changes:) …later

git stash pop

# Now git diff shows the original uncommitted changes

If git-stash-pop hits conflict on 1 file out of 3

  • the one file content will show >>>>. I will leave it alone for now
  • the other 2 files would show the original uncommitted changes. git-diff-HEAD would show these changes.
  • now I can use git-reset-HEAD and git-diff

git | fork auto-sync says

Fork syncing helps you to keep your fork in Bitbucket Server up-to-date with changes in the upstream repository. Bitbucket Server can do this automatically for all branches (and tags) you haven’t modified in the fork.

I guess forking (and pull request) is not a feature of GIT per se but a feature of Bitbucket and GitHUB server. I think the server get notified upon a new commit and runs fast-forward git pull.

git | rebasing: basics

For me, rebase is the procedure to re-sequence commits… A simple form of history rewrite.

git pull --rebase # moves your local commits to the end of the linked list
How do I merge multiple Work-In-Progress commits into a single commit?

The following will take the last five commits and give you an interactive session that allows you to (optionally) merge them.

git rebase -i HEAD~4

More details are here

git | diff tips #investigating merges

git diff –help # manpage

git diff –color-words # good

git diff -U22 # 22 lines of context

3 forms of diff — See 3trees@git

— diff of a merge-conflict file is different.

I think it is a 3-way diff. Output shows current “merged” file vs orig1 and orig2. explains “++”

— if you see a line showing up due to nothing but white space change, you can usually use “-w” to suppress it but sometimes you need to pinpoint the white space change:

git diff |cat -vet

— on linux, git-diff output seems to truncate long lines shows

git config core.pager 'less -r' 

git | reverting a file: various ways

I didn’t like git-revert as it complicates history. See

How do I revert a file to remove bad commits?

git checkout HEAD -- <file or directory>

This use of git-checkout is unrelated (as far as I know) to the commit-level checkout. This solution is officially /sanctioned/ … Some git commands would suggest …

(use "git checkout -- <file>..." to discard changes in working directory)

How to Revert non-commited changes

git reset --hard HEAD  # reverts tracked files back to the head
git clean -fxd .   # deletes untracked files in current dir. You may want to cd to the repository base first

[Victor] My vote for best explanation of git-reset goes to Detailed, but more readable than the manual. Many examples are useful to me.

Warning — if you want to temporarily play with an older version of, then be careful. Make sure you save the current tip of your branch. If you git-reset–hard then you may lose that tip!

How to Revert branches back to origin

git fetch origin
git reset --hard origin/yourBranch

git-cherry-pick commits to push to main branch

How to Cherry-Pick Commits to Push to main ‘develop’ branch

Say you are working on a feature branch with other people, with you all making commits and pushing to the remote replica of this branch. At some point you will want your commits merged with develop/production. Git does provide a method of choosing which commits you would like to push. The easiest way to explain this is with an example. We assume that all the following commands are run in a command line tool.

git checkout feature/commodity
git log -3 --pretty=oneline #look at the 3 most recent commits to the repository (includes all commits to all branches - in a nicely displayed format)
$ git log -3

Looking at this log, I want to push only the latest change to ‘develop’ branch (via a pull request), the commit associated with the e5a67d7088622dd8821dfdd8e2fafa2dc938b75c hash number. Keeping a record of this hash number I then create a new feature branch from ‘develop’ branch in Stash. Assume this new branch is called feature/cherry_pick

git fetch #update local repo to get this new branch info
git checkout feature/cherry_pick #switch to this new branch, at the moment is exactly the same as origin/develop
git cherry-pick e5a67d7088622dd8821dfdd8e2fafa2dc938b75c #where the hash number is the commit I actually want to merge into 'develop'
git commit #commit this change to the local feature/cherry_pick 
git push #push this change to the remote feature/cherry_pick branch

You can now create a pull request in Stash to merge this cherry-picked commit into ‘develop’

git | diff utils #two-repo

–Method: git-diff command

This is a basic but versatile tool. It looks at two commits you provide. Note each tag represents a commit. Each branch name also represents the commit at the tip of the branch.

–Method: have two local repos (clones) to check out different branches

Figure out how to clone two physical repos. After that you could use many conventional diff tools.
In 2019 again this proved 3 times more effective than all alternatives. I was able to check out two clones of the same repo, roll back one of them to an arbitrary commit (possibly on a branch) and use my favorite diff tool to slice and dice the large number of code changes. BeyondCompare is my favorite but it is sadly not free.

–Method: download remote version as complete file, then diff that against local file

Here’s my earlier favorite choice to diff a remote branch version vs a local branch version:

mv buildChoops.local
git checkout origin/feature/my_br6 # download the file from the remote branch into the current directory locally
... now run any diff tool between the two files

–Method: bitbucket/github comparison between branches/tags

Stash supports a directional PR diff, distinct from the git-diff command. Based on the pull-request concept, Stash treats your two commits as a FROM and a TO and shows the sequence of commits between them, as if in a pull-request.
If you click the arrow to reverse the direction, then Stash will always show a different diff result!
  • If from A to B there’s a fast forward merge, then Stash PR diff from B to A would show zero commit, since such a pull request would be empty.
  • If between A and B there’s no fast-forward merge, this PR-diff would show fewer commits than git-diff.
In summary, PR-diff is directional; git-diff is directionless. This directional diff feature is kind of unique to Stash and therefore valuable.

–Method: git diff using Beyond Compare 3

See more details in separate blogpost git+beyondCompare

–Method: git diff using Winmerge

see, updated June 2015

I hope there are similar solutions for other diff GUI tools.

tidy up messy commits, for pull request

Git – tidy up messy commits, for pull request

A common situation: you make many incremental, quick and dirty commits on your branch, undoing and redoing changes. You don’t need to push the entire history to a shared branch like Develop.

Many solutions exist. Git offers many commands to rewrite history on a branch. Many git users use them regularly. We could use them to clean up the commits on a feature branch before pulling them into a pull request. Here are some of the methods.

This will rewrite the history of your branch, you should only do this if no one is sharing your branch (or you don’t care about them).

1st approach – rebase, if your history is clean

This example will let you interactively select from the last four commits.

git rebase -i HEAD~4
# Alternatively, specify the last-good commit:
git rebase -i e8a9cf093   # Rebase all subsequent commits

2nd approach – If your history is too complicated (many merges etc.)

git tag backup                      # we do this so that we don't lose our history
git checkout -B temp origin/develop # checkout a clean temporary branch from develop
git merge --squash <branch>         # merge our old branch in, squishing all the commits
git commit
git branch -f <branch> temp         # force the branch to point at the new commit

3rd approach – git reset and commit again

Suppose you have 5 commits to squash,

git reset --soft <a previous commit hash, or something like HEAD^5> # rollback to the named commit.
# reset --soft modifies only commit history, not work tree or index.
# Now you can look at the files involved in those 5 commits, staged for the next commit
git diff --cached --name-status
git commit -m 'your msg'
# git push ... and create pull request

All methods so far assume the complicated commit history is in local repo not on a Stash branch. If your Stash branch has stuff you want to pull into Develop, but your Stash branch has complicated history, then …

4th approach – create a pull-request candidate branch

# create the candidate_branch from Develop, on stash
git tag backup                      # we do this so that we don't lose our history
git fetch                           # will show the new branch
git checkout candidate_branch
git merge --squash old_branch       # merge our old branch in, squashing all the commits
git commit                          # the default msg shows list of files. you might want to uncomment that in the msg.
git push origin candidate_branch    # now the candidate branch is up-to-date on Stash. Ready for pull request.

5th approach – rewrite public history

Dangerous – Know what you are doing
# clean up your local branch as illustrated above
git push --force origin   your_Stash_branch    # overwrite the Stash branch and overwrite public history - Dangerous!

6th approach – edit commit message after many merges, using git-filter-branch

The git-rebase and git-cherry-pick commands often fail in the presence of a complicated history of merges, file deletes etc. Try filter-branch.

Dangerous – can modify many commit messages by accident
# clean up the branch xyz
git checkout -b xyzRewrite # Always do the rewrite on a cloned branch please
git filter-branch --force --msg-filter 'sed "s/addYENRates/[CFMQUANT-262] addYENRates/" ' e635d034ea8..HEAD

At end of the command, 1st hash is the parent of the flawed commit. 2nd hash must be HEAD (or perhaps the name of a branch).

Command should tell you the branch is rewritten. If no commit message matches the pattern, then the command would tell you the branch is left unchanged, so it’s safe if you have a typo that matches nothing.

In either case, you can then run git diff against the original branch and verify they are identical content-wise.

In this real example we were lucky the message “addYENRates” was rather unique. If it shows up on 2 commits, then both would be rewritten.

gdb: dump STL container %%experience

First let’s talk about custom containers. GDB would show the field names of an object, but frequently not the values. I guess integers values might show up but more than half the fields are pointers ( actually char-array field would be easy to print.)

If I call a function on the object, I have to be very lucky and very careful. q(->) has never worked for me so far, so I need to use q(*) to de-reference every pointer before calling a method on the pointee, and pray it works. works on std::map …

A simple experiment using

  • g++ -g theFile.cpp && gdb -iex ‘add-auto-load-safe-path .’ ./a.out
  • (gdb) print *(li._M_impl._M_start+1) # can print 2nd element if it’s std::string or double
    • Note before vector initialization, gdb already shows the addresses inside the vector, but some addresses are not populated. Just retry after the initialization.
  • std::unordered_map is doable:
    • (gdb) print **(tm._M_buckets) # prints first pair in a hash table bucket
    • (gdb) print *((**(tm._M_buckets))._M_next) # next pair in the same bucket
  • std::map content is harder
    • (gdb) print *(int*)(tm._M_t._M_impl._M_header._M_left+1) # prints one key
    • (gdb) print *(int*)(tm._M_t._M_impl._M_header._M_right+1) # prints another key in the pair
    • (gdb) print *(int*)((void*)(tm._M_t._M_impl._M_header._M_right+1)+sizeof(int)) #prints the value in the pair.
      • the (void*) is needed before we add sizeof(value_type). Without the cast, the pointer arithmetic would be different.
      • from the key field to value field, we move by 4 bytes (i.e. sizeof value_type) from  0x6050e0 to 0x6050e4. It’s actually easy to manually type .. print *0x6050e4
      • I suspect the _M_right pointer is seated at the “color” field. Increment to the key field?

loading .gdbinit

My experiments show that $HOME/.gdbinit is discovered. I actually changed the $HOME env variable:)

However, I hit

  warning: not using untrusted file "/v/global/user/b/bi/bint/.gdbinit"

, even though I added q(gdb -iex ‘set auto-load safe-path …’). I guess the warning come up before the -iex option takes effect

  gdb -ix '/path/to/.gdbinit' # also failed due to untrusted file
  g++ -std=c++0x -g dump.cpp && gdb -iex 'add-auto-load-safe-path .' ./a.out # working

gdb symbol-loading too time-consuming

After I attach gdb, it immediately starts a prolonged symbol loading process. It’s better to skip the loading, and selectively load some symbols. describes how to use ~/.gdbinit, but I had no permission to write to the ~/

gdb -iex ‘set auto-solib-add off’ …. # worked

–loading a particular *.so file

I got “No loaded shared libraries match the pattern” and fixed it by

shar #instead of /full/path/to/

g++ q[-L] vs [-l] .. [-I] vs [-isystem]

-L and -l (i.e. the big and small "L") both affect the linker only.

See also MSVS linker option -L vs -l #small L

-L (similar to -I) and introduces a new search directory, for *.so or *.a file search.

Q: does the order of -l options matter?
A: yes. Recall the -liberty …

Q: does the order of -L options matter?

-I and -isystem both affect the preprocessor only.

There’s not “-i” option per-se.


bitBucket: investigate history of merges

Scenario: throughout the month, your main branch takes in many pull-requests. You want to see the sequence of merge points in chronological order.

On BitBucket, the commit listing is chronological but doesn’t show the merge commits. I usually unhide the merge commits, so on my page the merge commits are interleaved with “regular” commits in chronological order like

  • merg3
  • merge2
  • commit2c
  • merge1
  • commit1b
  • commit2b
  • commit 2a
  • commit1a
  • commit3a

The regular commits line up according to their commit timestamps. the most recent merge could have its one and only commit created months ago !

What I want is “nothing but the merge points”. I think I have to ignore the “regular” commits and only look at the merge commits.

git tag with annotation

I always want a long description for my git branch. Not sure how best to do it. has some suggestions.

— Git tag can have an annotation:

git tag -a newTag some_commit #create
git show newTag #reveal the annotation, creation time etc
git tag -d newTag #deletes the tag

Two ways to edit annotation:

  1. We can remove and re-tag with a modified annotation.
  2. git tag <tag name> <tag name> -f -a

jira Resolved^Closed

JIRA has two “fields” (one of them isn’t a field, but for this, it might as well be).

  1. The Status tells you where the issue is in the workflow. It does not tell you anything about the issue’s resolution, even though it might say “resolved”, “closed”, “done”, “fed to penguin”, it’s just an indicator of where it is.
  2. Resolution is either empty or populated (I consider it a boolean). if it is empty, JIRA sees the issue as “open” (and displays “unresolved” on screen), whatever the status is. It considers it “done” if it has any data value at all.

Resolved often means “developer put in the fix and feel confident but other people may not feel confident.”

Closed is a Status. It is the end status of the workflow and means “Reporter or QA confirmed that no more action needed. No need to look at it again, until reopened.”

In one workflow, when I Resolve a jira, status transitions to ReadyForQA.

git | diff highlights trailing space

By default there’s a default-enabled highlight (in red) of trailing spaces. I encounter it all the time when running git-diff. Extremely distracting.

$ git config core.whitespace  trailing-space # the dash before “trailing” disables it

Beware: when you copy-paste into a command window, the dash may become something else 😦

If successful, this command adds a line into .git/config like

whitespace = -trailing-space

You can remove this line to restore the “factory default”.

git | backup b4 history rewrite

Personal best practice. Git History rewrite is not always no-brainer and riskless. Once in 100 times it can become nasty.

It should Never affect file content, so at end of the rewrite we need to diff against a before-image to confirm no change.

The dumbest (and most foolproof) before-image is a zip of entire directory but here’s a lighter alternative:

  1. git branch b4rewrite/foo
  2. git reset or rebase or cherry-pick
  3. git diff b4rewrite/foo

Note the branch name can be long but always explicit so I can delete it later without doubt.

gdb to show c++thread wait`for mutex/condVar shows my experiment using gdb supplied by StrawberryPerl.

On this g++/gdb set-up, “info threads” shows thread id number 1 for main thread, “2” for the thread whose pthread_self() == 2 … matching 🙂

The same “info-threads” output also shows

  • one of the worker threads is executing sleep() while holding lock (by design)
  • the other worker threads are all waiting for the lock.
  • At the same time, the main thread is waiting in a conditional variable, so info-threads shows it executing a different function.

github tips #email

  • q(git config credential.helper store) is the command that finally fixed my git-bash forgetting-password problem on my win7 Dell. The github “recommended” command only worked in my win10 Lenovo and office win7:
    • git config --global credential.helper wincred 
  • On Linux, I only needed to run a simple command to cache my credentials
$ git config credential.helper store
$ git push 
Username for '': <USERNAME>
Password for '': <PASSWORD>
  • to comply with email privacy,
    • git config --global {ID}+{username}
      You can find it in
  • –to download an entire branch on the github web interface: CloneOrDownload button can download a zipfile
  • –to mass upload using drag-n-drop
  • I realize that the zipfile downloaded has a problem. When I open the zipfile (but not extract) and select the files, the drag-n-drop interface fails. I had to copy the files to a tmp directory.
  • –delete folder: not so easy
  • –file naming tips
    • ^ is slightly less ideal
    • I would use underscore as default and use dash sparingly (like 0-N). Camel case is even better.
  • –rename file @web interface is easy
  • –rename branch: no web interface. I had to …
    • checkout branch locally,
    • rename branch
    • commit
    • push, which triggered a login pop-up.
  • –rename folder: no web interface. I had to
    • git mv dir1 com/xx/dir1 # close MSWE if you get perm error
    • git commit
    • git push

git | origin/br1 ^ remote/origin/br1

In q[ git branch -a ], we see


I verified that

q[ git log remote/origin/br1 ] and q[ git log origin/br1 ] are identical

–To delete a local tracking branch without deleting the remote branch:

git branch -rd origin/br2

— my incomplete understanding:

There can be many remotes in a git repo. Each remote is “pointer” to a peer repo at some URL, identified by a nickname. The familiar “origin” is the default nickname of the remote you cloned from.

q[ git remote -v ] shows the URL and nickname of each remote.

gdb cheatsheet

#1 tip:
gdb –tui # starts an upper screen showing a moving marker against the current line. If you started gdb without “–tui”, you can still use Ctrl-X Ctrl-A.

#2 tip:
After hitting a breakpoint, you can use q(n) i.e. q(next) and just Enter to repeat previous q(n).

I found it easier to use q(break filename:lineno) # Filename doesn’t need full path J

Other essential commands

  • b myFunc
  • b myClass::myFunc
  • info break # or info b to list all breakpoints
  • · bt # or backtrace
  • · frame 0
  • · list
  • · p for print
  • · info variables
  • · info locals
  • · info args
  • · n # for step-over
  • · s # for step-in
  • · fin # for step-out
  • ctrl-L toclear gdb command screen

cvs rollback #basics

cvs -q update -D “2017-07-29” # will remove any file that’s “not in the universe” at that moment in history

The date means beginning of the day in GMT.  Here’s the more precise form:

cvs -q up -D “2017-07-29 00:00:01 GMT”

cvs -q up -D ‘2017/09/15 19:54:25 GMT’ # GMT make a difference. Default is … surprise.

–To verify the rollback

  • cvs log # is confusing and shows commits after the snapshot!
  • cvs stat path/to/file # shows the sticky tag

–To check the commits between two dates:

cvs diff -N -b -D “2017-10-20 22:00:00 GMT” -D “2017-10-20 23:00:00 GMT”

gdb –tui #split screen

You can also start gdb normally, then switch to split screen, with “ctrl-x  ctrl-a” (thanks to Gregory).

Upper screen shows the source code with a moving marker

–Here’s my full gdb command showing

  • –args to run the target executable with arguments
  • redirect stderr to a file so my gdb screen isn’t messed up — not always effective

gdb –tui –args $base/shared/tp_xtap/bin/xtap -D 9 -c $base/etc/test_replay.cfg 2 >

cvs update/checkout a file or dir

–retrieve an old version without sticky

cvs up -p -r1.17 CTFXdpIntgPlugin.C> CTFXdpIntgPlugin.C.1.17

–cvs update a dir or file:

cvs update –dA package/aida/common/script Bring working dir specified up to date with the repository (merge changes made to the repository into the local files).
cvs update –A package/aida/common/script/MakefileAida.sun4
Bring just the named file up-to-date with the repository

–cvs checkout a dir or file:

cvs checkout edu Checks out everything under edu, placing an edu directory, plus all subordinate subdirectories, in the working dir.
cvs checkout app/alh Checks out everything under app/alh placing an app directory in your working directory, but only the alh subdirectory of app.
cvs co package/aida/common/script/MakefileAida.sun4
Checks out only the single file MakefileAida.sun4, creating package/aida/common/script/MakefileAida.sun4 in the working directory, containing that one file.

q[g++ -g -O] together has a section specifically on debugging. It says

GCC allows you to use -g with -O

I think -g adds additional debug info into the binary to help debuggers; -O turns on complier optimization.

By default, our binaries are compiled with “-g3 -O2”. When I debug these binaries, I can see variables but lines are rearranged in source code, causing minor problems. See my blog posts on gdb.

gdb q[next] over if/else +function calls #optimized

I used an optimized binary. Based on limited testing, un-optimized doesn’t suffer from these complexities.

Conventional wisdom: q(next) differs from q(step) and should not go into a function

Rule (simple case): When you are on a line of if-statement in a source code, q(next) would evaluate this condition. If the condition doesn’t involve any function call, then debugger would evaluate it and move to the “presumed next line”, hopefully another simple statement.

Rule 1: suppose your “presumed next line” involves a function call, debugger would often show the first line in the function as the actual “pending”. This may look like step-into!

Eg: In the example below. Previous pending is showing L432 (See Rule 2b to interpret it). The presumed line is L434, but L434 involves a function call, so debugger actually shows L69 as the “pending” i.e. the first line in the function

Rule 2 (more tricky): suppose presumed line is an if-statement involving a function call. Debugger would show first line in the function as the pending.

Eg: In the example below, Previous pending was showing L424. Presumed line is L432, but we hit Rule 2, so actual pending is L176, i.e. first line in the function.

Rule 2b: when debugger shows such an if-statement as the “pending”, then probably the function call completed and debugger is going to evaluate the if-condition.

424 if (isSendingLevel1){
425 //……
426 //……….
427 //……..
428 //……….
429 } // end of if
430 } // end of an outer block
432 if (record->generateTopOfBook()
433 && depthDb->isTopOfTheBook(depthDataRecord)) {
434 record->addTopOfBookMarker(outMsg);
435 }

#1 challenge if u rely@gdb to figure things out: optimizer

Background: explains why “figure things out quickly” is such a make-or-break factor.

In my recent experience, I feel compiler optimization is the #1 challenge. It can mess up GDB step-through. For a big project using automated build, it is often tricky to disable every optimization flag like “-O2”.

More fundamentally, it’s often impossible to tell if the compiled binary in front of you was compiled as optimized or not. Rarely the binary shows it.

Still, compared to other challenges in figuring things out, this one is tractable.

gdb stop@simple assignments #compiler optimize

Toggle between -O2 and -O0, which is the default non-optimized compilation.

In my definition, A “simple assignment” is one without using functions. It can get value from another variable or a literal. Simple assignments are optimized away under -O2, so gdb cannot stop on these lines. This applies to break point or step-through.

In particular, if you breakpoint on a simple assignment then “info breakpoint” will show a growing hit count on this breakpoint, but under -O2 gdb would never stop there. -O0 works as expected.

As another illustration, if an if-block contains nothing but simple assignment, then gdb has nowhere to stop inside it and will only stop after the if-block. You won’t know whether you entered it. -O0 works as expected.

MSVS linker option -L vs -l #small L

Linker option –l (small ell) for the lib file name; -L for to specify the search path


Finally, you must tell the linker where to find the library files. The ST-Developer Windows installation contains programming libraries built for use with Visual C++ 2005 (VC8) and 2008 (VC9) with the /MD flag, as well as versions that are link compatible with other compilers. These are kept in different subdirectories under the ST-Developer “lib” directory. The library directories available for Visual Studio 2005 and 2008 are as follows:

  • $(ROSE)/lib/i86_win32_vc8_md (2005, 32bit platform, /MD)
  • $(ROSE)/lib/x64_win64_vc8_md (2005, 64bit platform, /MD)
  • $(ROSE)/lib/i86_win32_vc9_md (2008, 32bit platform, /MD)
  • $(ROSE)/lib/x64_win64_vc9_md (2008, 64bit platform, /MD)

Select the Linker category of properties and, pick the General options under that. In the Additional Library Directories property, add the appropriate ST-Developer library directory.


putty color

I tried various color schemes. None worked, so I found “monochrome with bold” good enough. That’s the fallback option. Now here’s one color scheme that might produce readable color on white background. In this case I turned on all the putty settings under Windows->colors:

  • tick AllowTerminaltoSpecifyAnsiColors
  • tick AllowTerminalToUseXterm256
  • tick AttempToUseLogicalPalettes
  • tick UseSysColors
  • radio group choose Both

Imperfection: in vi, I get yellow line number on white background 😦 so I had to go to Windows -> colors -> bottom scrolling list -> set ANSI YellowBold to 222:222:0

Whenever you turn on color support in terminal and in q(grep), you open a can of worm. Often LESS would need -R switch to cope with “ESC[01”

cvsignore troubleshoot`

gitignore  can be investigated. Git can tell you why a particular file is ignore. CVS doesn’t support that instrumentation.

If you need to confirm a file is explicitly ignored, then you can put a single “!” in ~/.cvsignore (as described in the official manual) to clear the ignore list.

%%first core dump gdb session

gdb $base/shared/tp_xtap/bin/xtap   ~/nx_parser/core

### 1st arg is the executable responsible for the core dump. If this executable is correct, then you should not get “No symbol table is loaded. Use the file command.” If you do, then try

(gdb) file /path/to/xtap

I think “symbol” means the variable/function names. I think gdb sees only … address not names. To translate them, presumably you need *that* file.

In my case the “xtap” executable is a debug-build, verified with “file” and “objdump” commands, according to

Anyway, we need to load the symbols. For a large executable (like minerva) with many *.so libraries, 30 minutes may be needed. Once the symbols are loaded, you should run “bt” to load the back trace

(gdb) bt

Now choose one of the frames such as the 2nd most recent function i.e. Frame #1

(gdb) frame 1

Now gdb shows the exact line number and the line of source code. You can see before/after lines with “list”. Those lines may belong to other functions collocating in the same source file.

(gdb) list

cvs cheatsheet

–top 10 how-to

  1. list modified files — 2 choices
    1. cvs -qn up # shows both untracked and uncommitted
    2. cvs status |grep # doesn’t offer a quick glance
  2. list untracked files in the current dir (git clean -fxd) —
    1. cvs -qn up | grep ‘^?’  # listing only
  3. cvs (git reset –hard)
    1. cvs up -C the/file
  4. checkout a single dir/file. First, cd into the parent dir , then 2 choices
    1. cvs up -d missingDir
    2. cvs co tp/plugins/xtap/missingDir # no leading slash. See for explanation

–Tier 2 (Still useful):

  • cvs -H any command
  • the -l option: -l Local; run only in top of current working directory, rather than recursing through subdirectories. Available with the following commands: checkout, diff, log, status, tag, update..

github branch backup

I plan to use bighub branches for backup:

  1. pick a single most valuable directory, like cpp (or py)
  2. once a while merge it into another branch like perl1 or bash
    • Watch out for any deletion of a directory like cppProj. You may need to merge the cppProj branch


  • Do NOT rely on this back-up. It’s a low-cost back-up with unknown reliability
  • more frequent back-up doesn’t hurt and should be quick and simple

git | %%tips { Macq

–to recreate current feature branch br2 as a clone of br3
The slower method is ” git checkout br3; git branch -d br2; git checkout -b br2″
The slightly faster method is “git reset –hard br3”

–Most git commands accept –help

  • Short Questions
    • How to rename a branch on Stash directly?
    • How to add a tag on Stash directly?
    • How to view the commit and annotation on one or multiple git tags?
    • How to add or edit the annotation of a tag on Stash?
    • How do I clean my external files?
    • How do I revert a file?
    • How do I get my local branch back to a remote?
    • Why is `git status` slow in Linux?
    • How do I list all branches that change a file?
    • How do I delete a local branch?
    • How do I merge multiple WIP commits into a single commit?
    • How do I get rid of obsolete remote branches
    • How to resolve pull request merge conflicts
    • A few ways to create new feature branch
      • Using command line without Stash
    • How to Revert non-commited changes
    • How to Revert branches back to origin
    • How to List names of modified files only
    • How to Cherry-Pick Commits to Push to develop
  • Using TortoiseGit
    • Overview
    • Some of the many convenience features
      • Feature: list of all uncommitted files (like git commit –name-status)
    • Installation
    • Using TortoiseGit
      • Setting up the Key
      • Clone the Stash repository (Workspace)
      • Interface 
      •  Commands
      • Enable icons in Win Explorer

Short Questions

How to rename a branch on Stash directly?

On your Stash page change base branch to the target branch (say BB) -> click on the “…” dropdown -> choose “Create a branch from here” -> specify new name (say NN) -> delete branch BB.

How to add a tag on Stash directly?

Navigate to the page of your chosen commit (such as this sample page), then find the link on the top right “Tag this commit”

How to view the commit and annotation on one or multiple git tags?

git show your_tag # look into one tag

The Stash page below also helps, provided the tag is published on Stash.

How to add or edit the annotation of a tag on Stash?

…  shows all tags, including the commit and the annotation. Choose one you want to edit and go to Actions column click the 3 dots and choose Edit.

Why is `git status` slow in Linux?

It might be due to the networked file system. We’ve found that doing the following might speed it up:

git config --global core.preloadindex True

See stackoverflow for details.

How do I list all branches that change a file?

git log --all --format=%H $FILENAME | while read f; do git branch --contains $f; done | sort -u

How do I get rid of obsolete remote branches

First remove it from Stash. Easy and safe to do on Stash web site. Go to the page listing all mod branches. Locate your branch you don’t want. Click on the “…” on the far right, to show the dropdown and find “Delete”. This would complete the deletion on the central repo. Next in your local repo, run

git fetch --prune

This command would sync up the local repo to match central repo on Stash. The deleted branch will now be deleted locally. Without this step, git branch -a would forever show the obsolete branch.

Remember each local repo or central repo holds a copy of all the branches. Deleting branch123 from one repo doesn’t automatically delete branch123 from another repo. Similarly, adding branch321 to one repo doesn’t automatically add branch321 to another repo.

How to resolve pull request merge conflicts

If possible, we use the Stash interface to merge. The resulting commit message on Develop branch looks like

Merge pull request #151 in CFMQUANT/mod from bugfix/tar to develop 

Merge pull request #147 in CFMQUANT/mod from feature/CFMQUANT-253 to develop 

Merge pull request #135 in CFMQUANT/mod from feature/CFMQUANT-243 to develop

Sometimes we get a conflict when merging the PR. For example, PR #153 has one file modified in the incoming branch release/0142c. Same file was very recently modified on Develop. Therefore this file had 2 concurrent changes, resulting in a merge conflict. This is what Victor did to resolve it, not necessarily optimal or recommended.


git fetch origin release/0142c
git branch -d develop
git checkout develop                    # check out latest from Stash
git merge FETCH_HEAD                    # one file in conflict, to be resolved
cd models/PyQXLModelsLib/ddl/
vi PyQXLModels_ddl_pycxx.cfg
git diff origin/develop PyQXLModels_ddl_pycxx.cfg    # ensure the diff is exactly what we expect
git add PyQXLModels_ddl_pycxx.cfg
git commit # see the comment message below
git log --simplify-merges               # verify
git push origin HEAD                    # may need special permission to push Develop to Stash

Here’s the commit message I used in the merge commit:

Merge pull request #153 manually from release/0142c to develop
[CFMQUANT-235] resolve minor conflict on one file



Using TortoiseGit


Another option for a visual interface for git under Windows is TortoiseGit.  This isn’t a GUI, as such, but a shell that sits on top of Windows Explorer.  Some people like it for this reason; some people dislike it for this reason.

It gives a convenient way to see the status of your files, and a convenient way (right-clicking) to select most commonly-used git commands (you can of course still use the command line whenever that is more convenient).  There is some pain involved in setting up the key for connecting to the server – scroll down to ‘Interface’ and ‘Commands’ below to see if you think the gain is worth the pain.

Git command line is rather rich and powerful, featuring hundreds (possibly thousands:) of commands + sub-commands + combinations of switches to those commands. ( lists more than 100 top-level commands). It’s impractical for any GUI tool to emulate the command line. Tortoise provides a good information-radiator tool, that saves you lots of repetitive typing.

Some of the many convenience features

Convenience is where Tortise distinguishes itself from other software tools.

In WinExplorer, Tortise lets you right click any modified file (or multiple files) to commit to your local branch. After the commit, the dialog screen lets you push to the central branch on Stash.

Similarly, if you have a new file to commit, you can right click and add, then commit.

You can also right click and diff with previous version.

Feature: list of all uncommitted files (like git commit –name-status)

You can show in a window a list of all files modified locally but uncommitted. You can then double-click each file to pop-up a diff screen, such as BeyondCompare. You can click to select one or more of these files to commit. For me this is the most convenient way to keep track of a large number of code changes. Same feature exists in TortiseSVN.

You can limit the scope to one directory (AgModels for eg). Within the same screen, you get a checkbox to widen the scope to entire repo.

There’s another checkbox to include unversioned (i.e. newly created) files. You can then add them to git with very few clicks.


TortoiseGit is free, and can be downloaded from  You’ll need to download the 64 bit version, and then run it (it will prompt for an x account password during the installation).  It does try to restart a lot of programs (so make sure you’ve saved everything), but doesn’t require a restart.  The default options in the install wizard worked fine for me.

Using TortoiseGit

Setting up the Key

For some reason, TortoiseGit only accepts keys in putty key format, so the key that works with Git needs to be converted to this different form (this should be a once-off).  An explanation of how is given here: (basically you need to download puttygen.exe to convert the format of the key).

Clone the Stash repository (Workspace)

To create a new repository based on the stash repository, you can use Windows Explorer to create a new folder, move into that folder and then right click, and choose “Git Clone…” to bring up a dialog box.

Set the url to ssh://git@….. the directory to where you want it installed.  You’ll need to click on “Load Putty Key” and put the address of the putty key saved down from puttygen earlier, which could be any stable folder in your C: drive. Avoid moving this folder.


Once successfully installed, Windows Explorer in folders associated with a workspace will now look something like

  • A green circle with a tick: up-to-date. (Victor: based on my earlier TortoiseSVN knowledge, a folder marked green means everything in it is in-sync with remote, a valuable knowledge.)
  • A red circle with an exclamation mark: file on disk has been changed and not committed (or for a folder, a file somewhere in that folder – possibly several folders deep – has been changed).
  • A blue circle with a question mark: “external” ie have not been added to the list of committed files
  • A yellow triangle with an exclamation mark: “conflicted” ie the equivalent of “overlap” in AccuRev

A full list of icons is given at


Right clicking on a file or folder brings up a menu of git commands.  Right clicking at the top of the directory tree means you can commit all changes, or click on merge to bring up a GUI interface to merge everything.

The full manual can be found at

If you are using a workspace that you set up outside of TortoiseGit (e.g. via the command line), then before you push to, or pull from, the server, you will need to point TortoiseGit to the putty key, by selecting TortoiseGit->Settings, then under “Git”, select “Remote”, then click on “origin” in the “Remote” box, and then set Putty Key.

Enable icons in Win Explorer

Victor had to fix his registry to get Windows Explorer to show the (nice little) icons. In addition to , he had to kill all Explorer.exe processes in taskmgr before relaunching Explorer.

Explorer “overlay” (technical jargon) is no mature and stable technology. Victor estimates a few times a year the icons would disappear on (subset of) the version-controlled files, often for no obvious reason, and then reappear at a random time. In spite of frequent disappointments, many users love these little icons.

eclipse to exclude a source folder

There is a straight way to do it:

  1. Right-click a project folder in Project Explorer tree and go to “Properties”.
  2. Resource -> Resource Filters.
  3. Add as much exclusion filters for files/folders as you like.

P.S. If your project tree is not updated automatically you may have to press F5 while having input focus in Project Explorer window.

std::string is usable in MSVS but can’t cout +! #include {string}

Many STL headers in Visual C++ (including iostream header) pull in a definition of the std::basic_string class (because they indirectly include the implementation-defined <xstring> header (never include that directly)). While that allows you to use the string class, the relevant operator<< is defined in the <string> header itself, so you must include that manually.

git-bash diff on win-word

beyond-compare… I haven’t configured it successfully.


  • Pandoc shows word differences, whereas default shows entire paragraph even for a one-word change
  • minor imperfections in the display of words near table boundaries

I added this chunk into my .gitconfig file:

 [diff "pandoc"]
   textconv=pandoc --to=markdown
   prompt = false
   wdiff = diff --word-diff=color --unified=1

waste time@c++IDE

c++ IDE build is 20% (up to 50%) more complicated than java, partly because c++ compilation is more complicated than java. Another reason is my previous investment in learning java compilation.

It can take many hours to fix an IDE project, but the long term return and leverage is questionable, since I use c++ IDE much fewer than java IDE.

Eclipse is my choice, although there are many usability issues and apparent bugs. Far from ideal.

Experience — devcpp is simpler.

Experience — codeBlocks xx isn’t worth the effort


git | 3trees

Three trees are 1) workTree 2)staging i.e. Index 3)HEAD or any commit before

A change can be in three states ( 1) modified locally 2) staged 3) committed. “Uncommitted” changes include 1/2. has a nice flow chart:

$ git diff HEAD # compares workTree vs HEAD
$ git diff # by default compares workTree vs staging/index
$ git diff –staged # compares staging vs HEAD, least useful. is my first and most memorable introduction on the three trees of git, in the context of git-reset.

—- git reset

In general, a commit procedure involves two transitions between three “trees”:

  • from local tree -> staging
  • from staging -> index

As a “treatment”, git-reset comes in three strengths:

  1. soft: reset the index tree only
  2. mixed: reset the staging tree too. #by default git-reset means q(git reset –mixed HEAD) and updates the HEAD ref + staging
  3. hard: reset local tree and all other trees

—-git diff –help shows a summary

$ git diff (1)
$ git diff –cached (2)
$ git diff HEAD (3)

1) Changes in the working tree not yet staged for the next commit.
2) Changes between the index (i.e. staged/cached) and your last commit; what you would be committing if you run “git commit” without “-a” option.
3) Changes in the working tree since your last commit; what you would be committing if you run “git commit -a”

git remote update

I had a strange problem

  1. I cloned a repo and had only one branch
  2. I know there’s a remote branch rb3, but
  3. git checkout rb3 # failed with “error: pathspec ‘rb3’ did not match any file(s) known to git.”

To investigate, I ran

  1. git branch -a # shows no trace of rb3
  2. git remote update
  3. git branch -a # now shows remotes/origin/rb3

I now think the problem was — I have a dir named ‘rb3’  !

git | manage feature branch #2delete

A few ways to create new feature branch

If you want the branch to show up in Stash, then it is probably simpler to create it on Stash website (choose the correct parent branch …). After that

git fetch # no arg after "fetch"... will show the new branch downloaded to local repository as "remote branch"
git branch -a # list all (local and remote) branches
git checkout feature/new_br_from_stash # creates a matching local branch

Using command line without Stash

git branch feature/my_br # creates a brand-newbranch named feature/my_br, in the local repo only.
git branch # lists all available branches in local repo
git checkout feature/my_br # selects my_br as the default branch.
git branch -m feature/my_BR # renames the default branch to feature/my_BR, in the local repo only.
git push origin feature/my_BR # creates and copies branch to Stash, assuming branch doesn't exist there.

(Note Git branches are designed to be disposable. So in theory you could create a branch for a small change and then merge and throw it away. No best practice no recommendatation yet.)

All feature branches, including temporary throw-away branches, can be deleted from Stash.

MSVS build (!!clean-build) unable to detect upstream changes

Let's avoid the confusing word “rebuild”. In MSVS it is name of a command to clean-build. In everyday English it means

1) An action to build again, or

2) The observation that a project built again, whatever the trigger

Therefore the word “rebuild” is vague and misleading.

Many of my 200 projects use boost 1.47. I kept the boost 1.47 files unchanged, and added 1.57 files in a brand new folder. I first changed the include path and linker path inside the shared property sheet, to use boost 1.57. Unknown to me, a few projects still reference boost 1.47 files outside the property sheets. Everything built fine.

Then I physically removed the 1.47 files. I thought all the 1.47-dependent /renegade/ projects would detect the upstream change and build themselves. We wish to avoid a lengthy clean-build at solution level, so we choose the incremental build.

Indeed as expected some projects “turned themselves in” as secret dependents of boost 1.47. But to my surprise, some projects didn't. So after build-all, these projects still use boost 1.47.

Lesson learnt – after removing the boost 1.47 files, we have to clean-build all. Cutting corners here could leave some 1.47 residuals in the artefacts.

git | branch sync – learning notes

Branching is different in git vs svn/cvs. By itself git branching isn’t too complex.

The git local/remote set-up is new to me. By itself, not too complex.

However, in reality we have to manage the combination of branching and sync – a higher level of complexity addressed in many online discussions. I would prefer to rely on the git commands (rather than GUI tools or Stash) to understand and manage it.

I like the philosophy in

–comparing the local branch vs remote branch

git diff feature/my_br6 origin/feature/my_br6 — path/to/your/file

–to see the mapping between local ^ remote branches

git branch -vv


–check out a remote branch? local branch to track remote branch?

–delete a branch locally, then remotely:

openssh^putty key files

openssh key format is the one used in id_rsa /

  • Proven tip: I actually took the pair of id_rsa files and used them in any windows or linux account. It’s like a single fingerprint used everywhere. The key is not tied to any machine.
    • The authorized_keys file in ALL destination machines have the SAME line containing that public key.
  • Proven tip: To support ssh support@rtppeslo2 with ssh key, I copy a standard authorized_keys to rtppeslo2:~support/.ssh. See

transformation — Puttygen can read the same “fingerprint” to generate ppk files, in putty’s format. Then a putty session can use the ppk file to auto-login, in place of a password

Note when my remote_host home dir permission was too open, then the ssh key was ignored by sshd. I had to enter password.

set up dependency between two c++ projects

I will mostly talk about MSVS but will mention linux build too.

The common methods to set up the dependency, all done inside project BB

1) specify project dependency in MSVS

2) define include path to cover the header from AA

3) define library path to cover the object file from AA

Suppose project BB uses “things” in project AA. Say a file in BB #-includes a header in AA. I think it's not necessary to have any. This is important when you debug the dependency. You may fail to find any trace of the dependency in any of those places. The file in BB can simply #-include the full/relative path to the header from AA. describes project reference vs project dependency….

….. much more to say.

MSVS debugger config #basics

Exe or DDL project types support debugging. You can specify an arbitrary command, like /full/path/to/Excel or /full/path/to/cscript. A few caveats:

When you press F5, are you in Debug or Release mode? Take note of that. When you put in the command, make sure you are in that same “configuration”. To play safe, I always set up for all configurations.

The command must be a single exe, without args. Args can only be specified in the Arguments field.

a MSVS SOLUTION imt a folder of MSVS projects

label: IDE, book

I agree the project is a more important development concept, but the solution also has unique, important functionalities. I found many of these functionalities from [[MSVS 2010 unleashed]].

* project dependency is described in the sln file.

* you can build an entire solution, according to the predefined build order

* a solution can contain so-called non-project items such as documentation. All such files are by default put into the “Solution Items” virtual folder. Rebuild ^ build


A) if a compilation is Rebuild, then it could be slow for a large solution. This is similar to MSVS solution rebuild

B) If a compilation is Build, then it can make use of whatever you have already built in MSVS, but if one of the projects was cancelled half-way it may come up as corrupted and break the nant build. I guess you can clean that project and rerun nant.

[15]Eclipse C++11/mingw xp

The default mingw download is too old for c++11. I tried mingw-builds project. Hit some problems. Probably failed to install or something else.

mingw-w64 — I found some workaround using a gcc 4.9 build — good for c++11. This 32-bit version worked in win7 and winxp —\

Note this is not an installer. When I tried the installer of mingw-w64 , it could (!) compile my c++11 code on the command line, but CDT couldn’t detect mingw gcc. Even after I cloned mingw32-gcc.exe, i still faced issues with #include . These are all well-known issues on the internet. Clearly this mingw-w64 installer isn’t better than the 7z download.

Lessons learnt –
* no need to upgrade. If your installation is a few years outdated, it may still work perfectly.
* standard installers may be “proven” for common tasks only, and a non-standard download could be high quality.
* Consistent with my past experience, env set-up is time consuming, esp. on the bleeding edge. In this case, both CDT and mingw have more than a single unified, consolidated release stream. Some users download from stream ABC and follow the versions therein. Other users download stream XYZ. Hard to share technical problems. Many of my installation issues were complicated by this “proliferation”.
* java (and py, c#) are easier since a single vendor releases all the versions

Eclipse CDT + gdb setup


PATH is a per-project config, not optional.

CCB->settings->toolSettings->g++compiler->misc -> turn on verbose to see which g++.exe in use
–c++11 mingw
mingw-builds installer either errors out or was too old… I  used mingw-w64 instead

install mingw and fix %PATH%. Go to mingw\bin\ folder. In dos, verify
g++ –version // gcc is the C compiler !!
gdb –version
copy the *make.exe to make.exe // needed in some of my projects
make –version
Even without IDE, I believe mingw g++/linker can convert your c++ source into executable. Mingw is designed to be usable without IDE. Both codeBlocks and eclipse users generally favor mingw over cygwin.

(Note you need the eclipse view “C/C++ projects” to see the Binaries + related stuff)

project properties -> Builders — I didn’t change.
project properties -> c/c++ general (CCG) — no need to change.
project properties -> c/c++ build (CCB) — contains every important config for C++. Amidst the CCB config maze, #1 factor is tool chain ( CCB->toolChainEditor ). Eclipse often defaults to CrossGCC + CDT_InternalBuilder [3]. Leads to this Question

Q1a: is that enough? mingw unnecessary?
A: I thought “Sometimes Partially Usable”, but I guess it’s an illusion, and we still need mingw.

Q: does eclipse come with gdb, so we don’t need to install mingw?
A: probably not. Apparently, gdb.exe must be in %PATH%

[3] To remind you which builder is in use, build console says “…. builder is used”

Now that’s the preliminary. Let’s zoom into compiling and debugging your project.
Q1b: does eclipse come with g++ compiler?
A: probably not. Eclipse looks for g++.exe in %PATH%, failing which it always always always fail to build.

Fix 1) First install mingw. Usually you can but sometimes can’t build using default crossGCC, in which case change toolChain=mingw (usually not needed). Should build a [projectName].exe, just as msvs. Runnable in dos.

Surprise #1 — by default, there’s no debug config for your project. I think that’s why you can build a good executable but can only run it in dos, not F11 — you get BinaryNotFound. That leads to …

Fix 2) create a debug config [2], in Run->RunConfig->c/c++App->new. Mention your [projectName].exe. If it’s not recognized as IDE-runnable, You may need to mess with the CCB->Settings->binaryParser (PEWindowsParser?) and restart IDE, rebuild…. Now you can run it in IDE, but you may or may not have problem debugging it. That leads to another Fix and Q&A

Fix 3) –>
Q: Minimum effort to fix debugging?
A: CCB->ToolChainEditor->currentToolChain = mingw. You can leave InternalBuilder alone.

[2] a debugConfig is also a runConfig.

## c++ instrumentation tools #mostly unfamiliar

(Each star means one endorsement)

oprofile **
gprof *
callgrind (part of valgrind)
sar *
strace *
(Compared to strace, I feel there are more occasions when ltrace is useful.)

*Pin threads to CPUs. This prevents threads from moving between cores and invalidating caches etc. (sched_setaffinity)

See more

remote debugging MSVS@winxp; app@win2008 or 2003 is the best guide I have found. Some comments —

Firewall – I didn’t need to change anything

— I ran the msvsmon.exe from a share. Just double click to run the exe
** msvsmon.exe need not run-as admin
** msvsmon.exe.config needs no change
** MUST add my name under msvsmon->tool->permission. Repeat in every msvsmon.exe session — Not saved.

— Attach to process
** transport = default
** qualifier = eqdpr@uwsamapos01, where eqdpr is the msvsmon.exe user on the remote
** refresh

Should see every process — Connected:) Once connected, before attach, msvsmon window will show who connected when.

You can start the remote app before or after Attach.

c# Release^Debug build # cheatsheet

Update – to the compiler, there’s no Release/Debug mode. I think this is really a MSVS feature. (The optimization diff between R/D is, ironically, less important to me. ) Each “mode” specifies a set of compiler/linker flags (+ env var). As a result, each mode has its own output directory for the build artifacts — they don’t overwrite each other.

Optimized – Release build could be faster, usually marginal difference. YMMV i.e. actual improvement depends on many factors.

Local debug – Release won’t hit breakpoints. Can it be fixed? Online says maybe but I feel YMMV.

Remote debug – Both Release/Debug builds supported. See

There’s a lot of discussion and Q&A on this.
* For our knowledge, it’s more relevant to know (at least a few of) the many optimizations.
* For practical coding, better know the restrictions on Release builds says
* The Debug configuration of your program is compiled with full symbolic debug information and no optimization. Optimization complicates debugging, because the relationship between source code and generated instructions is more complex.

* The Release configuration of your program contains no symbolic debug information and is fully optimized. Debug information can be generated in Program Database Files (C++), depending on the compiler options that are used. Creating PDB files can be very useful if you later have to debug your release version.

–Forum authors point out
Size of the release executable is smaller than a debug executable. In terms of execution speed, a release executable will execute faster for sure, but not always will this difference be significant.

One can expect to see funny errors in release builds due to compiler optimizations or differences in memory layout or initialization. These are referred to as Release-Only bugs.

books on MSVS

Most books are too thick and duplicates the very big MSVS documentation

[[ Mastering Visual studio .NET ]], available in Jurong East library, is one of the best but covers 2003. Covers debugging in-depth.

C++ and c# are the 2 implicit targets.

renaming folder in svn

C) Conservative approach – clone the folder, verify it, check in, observe [3], then schedule to remove obsolete folder.

** Caveat – Before removal, everyone needs to know the old folder is obsolete and not to be used.
** Caveat – history lost

[3] it can take months to uncover a problem induced by the renaming.

D) The tortise “rename” is convenient but potentially dangerous. Usually works. Acceptable on unimportant svn folders. Use your judgement.

MSVS project – Don’t include unversioned files

If a file is versioned and included in VS project, normal.
If a file is versioned and Excluded in VS project, then no real risk even if the file causes build errors.
If a file is un-versioned and included in VS project, then build will complain explicitly.
If a file is un-versioned and Excluded in VS project, then do you need to back up the file? If you do then better version it.

MSVS – adding x-proj reference within a solution

Say you are developing Project1. If you refer to stuff in a sister proj (Project “PROJA”) within the same solution, you must include PROJA in Project1’s References. You must see PROJA when you expand [1] Project1’s References list.


Now watch out. When you addReference -> Project, you may see PROJA. Now you must click OK. If you click Cancel, you will see PROJA not added to the References list.


[1] using that tiny “+” sign


single-stepping 4 stages of g++ compliation

First 3 stages are file-by-file; 4th stage merges them. You can use “file anyFileName” to check out each intermediate file, and cat it if ascii.
–1) preprocessor.
yourSourceCode => preprocessedSource — often 200 time larger.
Both ascii format.
to run this single step — gcc -E
–2) assembler. This is Before compiler.
preprocessedSource => assembledTextFile.
Both ascii format — yes for the assembler!
to run this single step — gcc – S
–3) compiler.
assembledTextFile => individualObjectFile
Ascii -> binary
to run this single step — gcc -c -x assembler
One object file for each original source file.
–4) linker.
individualObjectFiles => singleMergedObjectFile
Now executable.

Eclipse CDT copy-create project

Project Copy-create is easier than create-from-scratch. However, the new project is often broken, perhaps due to multiple CDT bugs:-(. Since CDT is buggy, i prefer external diagnostic tools.

* External — the exe file. ….\ideWorkspace\yourProject\Debug\*.exe. I call it “the EXE of the project”
Each clean-rebuild should recreate this file with a new timestamp. You can delete the file directly. If your main() ends with cin.get(), then you can run the EXE by double-click.

—– now, let’s look at how to copy-create —-
The copy actually copies the .exe as the EXE. I hate that name, so I run a text replace in
ideWorkspace\yourProject\.cproject. You need to reopen the project, clean and rebuild, then refresh the view to see the newly produced EXE.

You may need to create a run-config. To search for the EXE, use the browse button. However, CDT might say the EXE is not a recognized executable [1]. Occasionally You can ignore it and run the EXE externally, or through the run-config.

[1] If you prefer to fix that, change the project properties -> c/c++ build(CCB)->toolChainEditor->currentToolChain to minGW.

dev-cpp and mingw integration

My dev-cpp used to work. I later installed minGW and dev-cpp stopped working even when I compile the simplest program

Solution —
1. Download new MINGW compiler at and install it in C:MinGW
2. in Dev c++. right click on menu Tools>Compiler options.
3. in tab “Directory”, right click on “Libraries” and change “C:Program FilesDev-CppLib” to “C:MinGWlib”
4. Compile!

3 requirements to debug into c++from another language

The driver app (java, c#, MS-excel …) had better use dynamic linked library to access C++ code. (Not sure if a static library can suffice.) Before the app terminates, we attach our debugger (gdb, MSVC etc) to that process.,6419.0.html has a popular write-up about MSVC debugger. i guess if you use g++ to compile, then you may need gdb; if you used MSVC to compile, then you may need MSVC debugger.

Obviously We need source code used to compile the library. Of course, the library must be compiled with -G.

dbx commands

To start dbx, you can just type dbx without arguments

–the essential commands
print, stop

–critical but rarely used commands
attach your_pid # just a single argument
thread t@8 # select thread “t@8”
where 5

–most frequent commands
# cont — (or “c”) command to resume program execution. Currently,
threads use synchronous breakpoints, so all threads resume execution.
# status # shows all breakpoints. You need this after a lot of “cont”
# dump — in suspension mode, shows a lot of variables at that point in
# assign

list # src

–if your c-string is too long to 'print',
print strlen(longStr)
print longStr+788 # will print from that position to the \0

–help any_command

–(18) What are the major MT features of dbx?

The `threads' command will give a list of all known threads, with
their current state, base functions, current functions etc.
You can examine stack traces of each thread.
You can resume (`cont') all threads.
You can `step' or `next' a specific thread.
The `thread' command helps navigating between threads.

where is the svn ignore-list physically saved

If you instruct[1] svn to ignore a dir, that instruction is physically saved in your local parent_directory/dir-props.

Now tortise will show parent_directory as “modified”. 

Tortise context menu -> svn property — will show it.
Tortise context menu -> check for modification -> look into “Status” column (one word) — will also show the exact change

[1] by IDE, Tortise or command line

basic eclipse c++ Q&&A

Q: project rebuilding — the exe is permission-denied
A: perhaps the debug shows the exe still in use.

Q: funny/weird characters in error messages and tooltips?
A: define environment variable LANG=en_US.ISO-8859-1 in Window->Preferences->C/C++->Environment
A: In toolchainEditor (TCE) if you chose cross GCC, you can get cleartext error messages. You also see Includes in Project view

Q: binary not found
Maybe there’s nothing for this Project under runConfig? Your *.exe (full path) should show up.

Q: basic includes for every *.c file?
using namespace std;

Q: “This application has requested the Runtime to terminate it in an unusual way. Please contact the application’s support team for more information.”
A: perhaps you access argv[1] without any command line arg?

Q: where’s the *.exe file generated for my project?
A: in the Debug folder

Q:’strlen’ was not declared in this scope
A: #include

Q: undefined reference to `WinMain@16′
A: no main()

eclipse mark-occurrence on vertical side ruler

One of the top 10 productivity features in Eclipse.

Preferences -> search for “occur” -> MarkOccurrences -> Annotations ->
Occurrences and WriteOccurrences -> Choose 2 distinct colors that are
easy to differentiate on the vertical rule and also as text highlight.

Q: How about Visual Studio?
A: I found that if I select a variable, move mouse away, then all occurrences are highlighted within the editor (not on vertical ruler). It’s known as “highlight reference” in MSVS. To change the highlight color, see

10 cool features of notepad++

#1a) The UltraEdit feature — You can type “insert table_2 select” and see it showing on 5 lines as you type.
#1b) select/remove a column of text. Contrast Alt-drag vs regular drag.

#2a) highlight open/close brackets across lines. See red dotted vertical line if you set tab size to 1 or 2. The missing Eclipse feature.
(View -> show symbol -> show indentation guide)
#2b) highlight open/close brackets on the same line
(Settings->Preferences->Misc->highlight matching tags)

#3) smart highlight (Preferences->Misc) highlights all occurrences once you select a word
#3b) permanently mark all occurrence of any string (partial word, multiple words..) See

#4) “update silently” and “scroll to last line after update” (preferences->Misc->File Status Auto-Detection)

#5) double click on a tab to close the document

7a) If you are at the closing tag of a long block, you can jump to the opening tag. (TextFX -> quick -> find matching bracket, with Shortcut Key)
7b) You can also highlight the entire block (TextFX -> quick -> mark)

) (View -> Hide Line) to hide a block of lines
) minimize to tray, to un-clutter the task bar
) to extend vertical space, hide toolbar or menu bar, put tab bar
) “reloadFromDisk” is nice but you can map a custom key (like F5) high latency
) vertical (Preferences->General)

mvn – which settings.xml is/are in effect@@

Q: when there are multiple mvn settings.xml files, which file(s) is/are in effect?

A: make the xml malformed and try a basic mvn command (see tutorials) to see which settings.xml file is picked up.

Eclipse mvn plugin actually merges global settings.xml + user settings.xml.

Stackoverflow says –

“Maven always uses either one or two settings files. The global settings defined in (${M2_HOME}/conf/settings.xml) is always required. The user settings file (defined in ${user.home}/.m2/settings.xml) is optional. Any settings defined in the user settings take precedence over the corresponding global settings.”

svn tagging^branching

Definition — A Tag in CVS can be read-write tag, but here we are ONLY interested in readonly tags ie snapshots.

The svn-book chapter [[cheating a simple tag]] ( addresses the common task of ROtag. A few key points —

* as long as nobody ever commits to a ROtag, it forever remains a snapshot/ROtag.
* If people start committing to it, it becomes a branch/RWtag.
* In Subversion, there’s no difference between a tag and a branch. Both are copy-on-write directory copies.
* when you create a ROtag, you can optionally specify a revision number. See The Chapter.
** a revision number is always a ROtag ie a snapshot of the filesystem after each commit.

* unix hard-link functionality
** copy on write
** cheap copy
** Make branches/tags as often as you want

When you copy a directory, you don’t need to worry about the repository growing huge—Subversion doesn’t actually duplicate any data. same concept behind a unix hard link. It duplicates data only when it is necessary to disambiguate different versions of objects — copy on write.

putty — save host-specific config

A host-specific config is saved in a so-called saved-session. To access the list of saved-sessions, go to, paradoxically, _New_Session.._

To see or modify a particular saved-session, you must first Load it. You may need to hit Load several times. Once you are in the “editor” mode on a saved-session,

  • * Navigate to a particular tree branch, like Window
  • * change a particular value there
  • * There’s no Save button. You must navigate back to the original Session page, and hit Save (repeatedly:). This Save button
    ** saves all the settings in the editor
    ** saves them under the session name.
  • * If a parameter has an unsavable value, system will _silently_ drop the change and rollback. seems to be a good FAQ for this.

How about the config file for each connection? Apparently putty uses registry…

–DefaultSettings as a template: save it if you repeatedly use this template.

launch -> select DefaultSettings -> LOAD -> change any setting -> come back and (click to) highlight DefaultSettings -> SAVE

MSVS ^ other c++ IDEs on windows

–regarding apps FOR linux
Options: eclipse, codeblocks? Well, I don’t trust the GUI on linux. I’d avoid all GUI IDEs. the Barcap FI c++ team basically uses visual studio + vi to develop c++ apps for Linux.

case closed — no IDE on linux for me.
On windows, front runners are eclipse, codeblocks and msvs. I tried CB — too complex to learn. To be fair, these 3 IDEs are equally complex but I have prior experience with eclipse (due to java) and msvs (due to c#).

Msvs has the most books, online resources and user base — largest support network. Reason? I guess for anyone building apps for windows, msvs is the defacto standard. Many textbooks use msvs shows Boost also supports VS as the primary windows IDE.

Msvs is not free, but some say the freeware MSVSE has c++

Both eclipse and CB uses mingw/gcc, but for apps running on windows, the microsoft compilier is the standard.

Compile a boost regex/thread-based project – minGW

You configure the -L under project -> properties –> CCG -> LibraryPath

You configure the -l under project -> properties -> CCB -> settings -> toolSettings tab -> MingwC++Linker -> library
— regex
cd C:xbakideWorkspaceec_boost1Debug
g++ -IC:boost_1_44_0 -O0 -g3 -Wall -c -fmessage-length=0 -osrcec_boost1.o ..srcec_boost1.cpp
g++ -LC:boost_1_44_0stagelib -oec_boost1.exe srcec_boost1.o -lboost_regex-mgw44-1_44

— boost::thread is more complicated cos the lib file(s) you built with bjam seem to be a hybrid of static and dynamic lib. Perhaps a static import library used to pull in the dll file (yes there is a dll produced). In that case, at runtime the dll must be available on PATH.

cd C:xbakideWorkspaceec_boost1Debug
g++ -IC:boost_1_44_0 -O0 -g3 -Wall -c -fmessage-length=0 -osrcec_boost1.o ..srcec_boost1.cpp
g++ -LC:boost_1_44_0stagelib -Bstatic -oec_boost1.exe srcec_boost1.o -lboost_thread-mgw44-mt-1_44

If you see error about missing dll, then copy the named dll to the location of your exe, or a %PATH% dir. Why the error? Dependency Walker shows LIBBOOST_THREAD-MGW44-MT-1_44.DLL is a dependency of your new born exe. Apparently, there’s no real static linking of the boost thread lib.

Build simple boost project]EclipseCDT^codeBlocks has a simple program using Boost Lamda.

1) immediately clean the project. Eclipse will rebuild and fail due to include path

2) Project -> Properties -> CCG -> pathsAndSymbols -> Includes -> GNU_C++ -> Add -> file system …
…I took the laziest route and simply put in “C:boost_1_44_0” to ignore all checkboxes, and it worked. I used a forward slash and it worked too. However, I removed it and put in “C:boost_1_44_0” and checked all 3 checkboxes -> compiler can’t resolve “#include “

(msvc procedure is well-documented.)

codeblocks is easier with include path — Project -> BuildOptions -> SearchDirectories -> Compiler -> Add

eclipse features i learnt recently

* add source code to spring.jar
* limit Problem view (compile errors) to just the project i’m in
* you can remote debug even if your project has compile errors
* export libraries from a project
* launch configuration, using ant targets — clean, build
* search filter in Preferences
* suspend all threads upon an exception
* do not convert line delimiter when checking out from cvs
* change the order of libraries on a build path, to avoid loading a bad version of a class.
* switch between 2 JRE run-time libraries.
*To “show system threads” like GC thread in eclipse, Go to the thread view, look for a small triangle to the far right -> java -> you get a few options on thread listing.

* If you add this line to your method javadoc, then the mouse-over javadoc in eclipse will show a hyperlink to the replace() method javadoc

     * @see java.util.concurrent.ConcurrentMap#replace(Object, Object, Object)

* separate workspace dir from source code physical dir
* eclipse -clean
* refresh a project to fix incomplete build path
* show empty/parent directories in Package view
* Advantage of Outline view over Package view — If cursor is in method1(), then method1() will be highlighted in Outline view, not in Package view.
* show views -> error log

aqua studio tips

* Ctrl-D (menu bar -> Query -> Describe) — Quickly see table properties
* Ctrl-F12 (menu bar -> Window -> …many items..) — hide list of servers on the left to get more real estate. There are similar tricks to save real estate. See “many items” above.

* to copy paste many rows into a temp table, List of servers on left pane -> choose your server -> Choose your database -> choose your table -> Right click -> Edit Table Data (Top 1000). Works for muni but not tempdb

* to turn on auto-complete, try Ctrl-Shift-U and Ctrl-Shift-O repeatedly until 2 buttons near MaxResults are depressed. The 2 buttons are AutoComplete and AutoOnAllSchemas

* If you see too many databases along with “master”, try
** Server Property -> Filter -> Filter Databases -> Exclude all
** Included Databases -> enter “tempdb”
** List of servers on left pane -> choose your server -> Choose your database -> Ctrl-Q