Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Wednesday, August 24, 2016

Shorthand for Git upstream (tracked) remote branch

It's @{u}.

For example, if you are on master branch, and master branch is tracked with origin/master. You can use git merge @{u} instead of git merge origin/master.

Reference: https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches#upstream-shorthand-k9UotnHmIO

Tuesday, June 16, 2015

Sort file name by number of changes in git history

git log --pretty=format: --name-only | sort | uniq -c | sort -rg | less
Literally copied from the answer of "Finding most changed files in git"

Thursday, February 27, 2014

[Git] Prune when fetch/pull

When a branch is removed from your git central server, remote branch on your machine won't get removed automatically. You might already know popular command to clean those removed branches, which is
git remote prune origin
But also you could give --prune or -p argument to fetch or pull to do the pruning for you after it's done with its normal behavior. For example,
git fetch -p
git pull -p
If you are in the habit of using remote prune that's fine. These prune arguments just save you one extra step if you just put them in to help cleanup once in a while.

Thursday, August 18, 2011

Git - Global gitignore

Some types of temporary files are spanding across project, such as .swp (VIM temporary file type).

To put *.swp to every project's repositories makes duplicate job.

One way to solve this issue is to put it to Global gitignore.

From this blog Git global ignores, i will copy to here, also.

- Create .gitignore file at somewhere, mostly at ~/
git config --global core.excludesfile ~/.gitignore


- An pattern of file, you want to do global ignore in to that file.

That's it.

Thursday, February 24, 2011

[Git] Rebase

So far I have used git rebase for 3 scenarios.
  1. Want to add more change in the commit that is not the last commit of any branch. Use git rebase -i
  2. Want to move whole different branch to base on another branch.
          A---B---C topic
    /
    D---E---F---G master
    to
                  A'--B'--C' topic
    /
    D---E---F---G master
    git checkout <branch-to-move>
    git rebase <base-branch>
  3. Want to move part of different branch to base on another branch.
        o---o---o---o---o  master
    \
    o---o---o---o---o next
    \
    o---o---o topic
    to
    o---o---o---o---o  master
    | \
    | o'--o'--o' topic
    \
    o---o---o---o---o next
    git rebase --onto <new-base-branch> <old-base-branch> <move-branch>


Wednesday, February 23, 2011

[Git] delete/remove remote tag

To delete/remove remote branch in Git, you use
git push <remote*> :<branch-to-remove>

Also to delete/remove tag in remote server, you can use
git push <remote> :refs/tags/<tag-to-remote>

These commands might seem weird and hard to remember. To be able to remember them easier, I suggest you to see this full git push command
git push <remote> <local-branch-name>:<remote-branch-name>

Then to delete is to push empty branch to expected branch on remote. That's all why.


 *remote is an alias of other repository see git remote
Credit: How to: Delete a remote Git tag

==

Update
The current version of git now support argument --delete for push. So now you can delete branch hello from origin with this command
git push --delete origin hello

Wednesday, February 16, 2011

[Git] Ignore change of a file that is in an index

There is a command git update-index --assume-unchanged <file> for ignore.
And there is a command git update-index --no-assume-unchanged <file> for unignore.

For listing assume-unchanged files use git ls-files -v and see lower h in front of file name.
You can combine this with grep "h ". And you can also use git ls-files -v if you are interesting only a file.

[Git] partially add some changes in a file to index

- Use git add -i (<filename>)
- Select 5 (or p) then enter to see changes for selection.
- Choose files by type number in front of each file name and enter.
- Enter again to start.
- Type y or n to choose or not choose changes.
  Type s to divide changes to smaller sectioin.
  Type e to manually choose change.
- After back to main prompt choose 7 (or q) and enter to leave.

Wednesday, February 2, 2011

Generate current Git version in Ant for Hudson

At the time I wrote this blog there is no Git Ant task. Workaround for getting current commit version is to use exec directly invoke git describe as below.
<exec executable="git" outputproperty="build.commit">
    <arg value="describe"/>
    <arg value="--tags"/>
    <arg value="--abbrev=20"/>
</exec>

Now you can get result value of git describe from ${build.commit}.
Credit: How to lookup the latest git commit hash from an ant build script - Stack Overflow

But there is also some problems with Hudson's git plug-in which it always tags build revision that causes our git describe return the wrong result. There was someone send patch to fix this but this is not build to the plug-in yet. Currently workaround is provided in that patch page, add paramter to git describe, "--match=[^(hudson)]*", to ignore tag from Hudson. So we have to add more arg line to Ant's exec task:
<arg value="--match=[^(hudson)]*">

That's all.

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...