例如,如果我在分支上,我想获得分支名称。但如果我处于分离的HEAD状态,我想获得提交ID。
基本上,我正在寻找.git/HEAD
文件的接口。我知道我可以cat
它,但也许有一个命令会为我做这件事(这样我就不必处理像GIT_DIR
这样的边缘情况不在我身边{ {1}}等。)
答案 0 :(得分:4)
如果您正在使用git completion https://github.com/git/git/blob/master/contrib/completion/git-completion.bash。通常会自动安装。
你可以打电话
MyReceiver post_r;
Context context;
String newValue;
public void refresh() {
//your code in refresh.
Log.i("PostRefresh", "Post:YES");
}
public void onPause() {
super.onPause();
LocalBroadcastManager.getInstance(context).unregisterReceiver(post_r);
}
public void onResume() {
super.onResume();
post_r = new MyReceiver();
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(post_r,
new IntentFilter("EDIT_TAG_REFRESH"));
}
// OnResuming get the details from second Fragment
private class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
YourFirstFragment.this.refresh(); // presend Fragment Name
String action = intent.getAction();
st_value1= intent.getStringExtra("Key1");
st_value2= intent.getStringExtra("Key2");
// EITHER SET THE VALUES HERE OR IN REFERESH METHOD
}
}
否则使用。
echo $(__git_ps1 '%s')