我的计算机上有一个文件夹,它是一个git repo。
此文件夹包含一个名为fileA
我想在所有(或所有子集)已落实版本str
的内容中搜索字符串fileA
。
有可能吗?
我不是git方面的专家,我使用SourceTree来管理仓库。
我对任何解决方案都感兴趣。例如,使用GitLab或GitHub的解决方案对我来说很好。
已给出了通过终端中执行命令的解决方案。
SourceTree是否有解决方案?
答案 0 :(得分:1)
请参见grep-all别名:
public class SessionActivity extends AppCompatActivity {
private Button btnDownload;
private String userName,passWord,getUrl,htmlData,divElement;
private NotificationManager mNotifyManager;
private NotificationCompat.Builder mBuilder;
String URL = "https://s3.amazonaws.com/sample.pdf";
private static final int PERMISSION_REQUEST_CODE = 200;
private boolean checkPermission() {
return ContextCompat.checkSelfPermission(this, WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(this, READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
;
}
private void requestPermissionAndContinue() {
if (ContextCompat.checkSelfPermission(this, WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(this, READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, WRITE_EXTERNAL_STORAGE)
&& ActivityCompat.shouldShowRequestPermissionRationale(this, READ_EXTERNAL_STORAGE)) {
AlertDialog.Builder alertBuilder = null;
try {
alertBuilder = new AlertDialog.Builder(this);
} catch (Exception e) {
e.printStackTrace();
}
alertBuilder.setCancelable(true);
alertBuilder.setTitle(getString(R.string.downloadCompleted));
alertBuilder.setMessage(R.string.downloadCompleted);
alertBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void onClick(DialogInterface dialog, int which) {
ActivityCompat.requestPermissions(SessionActivity.this, new String[]{WRITE_EXTERNAL_STORAGE
, READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
}
});
AlertDialog alert = alertBuilder.create();
alert.show();
Log.e("", "permission denied, show dialog");
} else {
ActivityCompat.requestPermissions(SessionActivity.this, new String[]{WRITE_EXTERNAL_STORAGE,
READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
}
} else {
openActivity();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == PERMISSION_REQUEST_CODE) {
if (permissions.length > 0 && grantResults.length > 0) {
boolean flag = true;
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
flag = false;
}
}
if (flag) {
openActivity();
} else {
finish();
}
} else {
finish();
}
} else {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
private void openActivity() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_session);
if (!checkPermission()) {
openActivity();
} else {
if (checkPermission()) {
requestPermissionAndContinue();
} else {
openActivity();
}
}
final Intent Intent = getIntent();
userName = Intent.getStringExtra("number");
passWord = Intent.getStringExtra("birthDate");
String txt4 = ".pdf";
String url3 = URL + userName + txt4;
btnDownload = (Button) findViewById(R.id.btnDownload);
btnDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String txt4 = ".pdf";
new DownloadTask(SessionActivity.this, URL);
}
});
Button imageLogo = (Button) findViewById(R.id.btnviewslip);
imageLogo.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String url = "file_url_to_download/";
String txt3 = ".pdf";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(URL + userName + txt3));
startActivity(i);
}
});
}
}
别名用grep-all = !"f() { git rev-list --all | xargs git grep \"$@\"; }; f"
列出了所有分支中的所有修订,并在每个修订版上运行git rev-list --all
。
要使其适合于抓取一个文件
git grep
PS。完全披露:我是链接存储库中的贡献者和审稿人。