Is there a way to search all branches/all their versions for some string? Essentially the equivalent of doing ctrl+shift+f to search the entire solution...but for all versions and branches?
Longshot, but figured I would ask. If not, is there at least something for file name? Asking about github.com, but if it's in gitshell, that's cool too.
My dear friends decided to delete some code at some point in a branch that wasn't merged.
While this would be using Git instead of GitHub's web interface, how about something like this?
git log --all --source -S"Some string"
There is also a -G option that does regex instead of -S. The details are there if you do a
man git log
The only negative here is that it assumes you've already cloned the repository.
Related
TL;DR: What is the least intrusive way of migrating existing files to the LFS storage, once LFS has been initialized on the repository, and a suitable .gitattributes file has been prepared but not yet pushed, for a Unity project using Github, Git LFS and SourceTree?
Software/services used:
Unity 2020 LTS
Github
Git LFS, which is part of Github
SourceTree
Links I'm using:
Githubs own migration tutorial
Githubs documentation for the migrate command
A .gitattributes file, which handles casing-differences in extensions using RegEx (I think).
Another answered question very much like this one.
I also took a look at BFG Repo-cleaner, but it seems a bit much for this task.
Motivation for posting
I've been trying to find a guide describing the best way to do this, but most seem to be out-dated or don't include enough information for me to be confident in firing these import-commands on my repo. Others focus a lot on how to set up LFS using a specific server backbone, like Bitbucket Cloud, but I can't find any focusing on Git LFS and SourceTree.
SourceTree has direct integration with Git LFS, but there seems to be no UI-implementation of the migration process for existing files in the repository, so I think I have to rely on the terminal for this part (which I honestly haven't had to use in years, so there's that).
I also have a question about a command for this that I don't see mentioned in my contexted searches: --fixup
The setup
It's not a huge repo; it's a main branch with a few dead branches that don't matter. I just want all the files with certain extensions converted to LFS. My initial thought was to do the migrate-command with --norewrite, because I liked the idea of compacting all the changes into one commit and have no changes to the commit history, but when I realized that means the files would have to stay in the repo for posterity, I changed my mind. I want the repo to shrink, as well, which means I want to replace the files with pointer-files back through the commit history, in order to eliminate the actual files from the repo completely, so they only exist in the LFS-storage.
My questions and options, as I see them
In that other answered question I linked to, a full answer isn't given, but it's very close. Though the answer is very informative, it doesn't answer these questions:
How to handle case-sensitivity surrounding extensions when writing migrate-commands with --include and --exclude options? Do I need to either go through all existing files in the repo and ensure a similar casing in order to do one-liners, or alternatively fire a separate line for each permutation of the extension I find in the repo? (ignore this question, if --fixup understands the casing-format mentioned in 2. and works for my purposes).
I see that there is a --fixup option for the migrate command, which isn't mentioned in the search results I'm getting with the given context, except in Githubs documentation for the migrate-command. It says:
"Infer --include and --exclude filters on a per-commit basis based on the .gitattributes files in a repository. In practice, this option imports any filepaths which should be tracked by Git LFS according to the repository's .gitattributes file(s), but aren't already pointers."
Is there some reason why the --fixup option isn't recommended anywhere, when it seems to do exactly what I need? Does it not rewrite the history, or something?
I hope it works, because since --fixup reads the .gitattributes files, it should be able to read the different casing-options from the casing-format in the .gitattributes files. Then I don't have to worry about missing files due to different casings, like when using the --include option.
This is the casing-format used in the .gitattributes file (example for .wav files):
*.[Ww][Aa][Vv]
It works for .gitattributes' normal workings, but doesn't work when you use the format for the --include or --exclude options for the migrate-command, e.g.:
git lfs migrate import --include="*.[Ww][Aa][Vv]"
...does not work. This is what gives the casing-issue mentioned in 1.
I have LFS initialized. I have my .gitattributes file (uncommitted) at the root of the project. So, committing and pushing .gitattributes, and then doing 2. seems to be what I want, right? I should be able to open the terminal in SourceTree, and put in this line:
git lfs migrate import --fixup
or do I need --everything, in order to affect all branches?:
git lfs migrate import --everything --fixup
Also, if --fixup doesn't work, is it just a bunch of these?:
git lfs migrate import --everything --include="*.WAV"
git lfs migrate import --everything --include="*.wav"
...followed by a:
push --force
or
push --force --full
???
That's about where I'm at. I'm not entirely sure which way to go here, or how each of these commands affect the result. I'd appreciate any input on what would be the best course here. If anything, I've tried to be as informative as I can and include the best sources I've found on the subject, to help anyone else asking the same questions.
EDIT: I found this issue at the Git LFS repository, which describes a caveat with the --fixup option; it takes into account when the existing files were added to the repo, and if they were added before the changes to the .gitattributes-file, then they aren't included. So, it is recommended to either rebase, or use filter-branch or filter-repo, in order to add/change the .gitattributes file at the root commit, so that the --fixup option will register the files. The issue deals with some more caveats, like having to uninstall LFS first, but eventually found that solution. This is all just to avoid having to do separate calls for each extension-casing permutation. I don't want to do any of those suggestions, since some seem to run into trouble with them, and I can't get --fixup to work with info, meaning I can't preview what it'll change, so I'm going with --include calls, and just searching up all the current permutations of the extensions of the existing files, and doing --include calls for those. Please, if you do have any good information on the subject, I (and probably many others) would love to hear some easier solutions to this problem.
Thanks in advance and best regards, Jonas Tingmose.
Is it possible to save github commits (info about commit, branch, author etc.) to file and create graph with branches as image?
I don't want to make repository public, but I need to share my progress without giving access to repo.
I'm not 100% sure this is what you're looking for, but using the git commands you can do that sort of thing. Clone the repo on your machine, cd to the repo, then you can do something like :
$ git log --graph --decorate --glob="*"
See screenshot below.
If you don't need to do this from a script, you can just copy-paste the terminal output. Otherwise, I'm sure there's a way to place it all into a file.
This graphical output is, IMO, quite useful. I personally use git hist as an alias of the verbose command above.
This is the best solution I found, git log output as HTML file:
https://github.com/bluef/gitgraph.js
Anyway, #Anthony D. provided pretty simple and clean solution.
I've tried to use the advanced search feature of Github, but when I search "specific text" repo:company/project/tree/specific_branch it does not return the desired results. It only seems to search master branch.
I too was looking for this. but this support in not available as per github help.
Due to the complexity of searching code, there are a few restrictions on how searches are performed:
Only the default branch is considered. In most cases, this will be the master branch.
Only files smaller than 384 KB are searchable.
Only repositories with fewer than 500,000 files are searchable.
Update: There's Hubscovery which probably solves the problem.
I understand that you've been asking about a way to use GitHub's own tools to do the search. After a brief overview I could not find a solution there.
But any GitHub repo is a Git repo. So you are free to use the power of console commands. There's a git grep command, allowing you to search for lines matching a pattern throughout the repository.
git grep 'search-string' $(git ls-remote . 'refs/remotes/remote_name/branch_to_search_in' | cut -f 2)
Instead of remote_name/branch_to_search_in put the actual names of remote and branch.
This example is based on the code from other SO question.
I am trying to correct a typo i.e. spelling mistake in the name of of github fork I have created. Drop a "t" from gwt-hightchart-dashboard-demo to gwt-highchart-dashboard-demo
I am not able to find out how to do this simple exercise after going through a few google/stackoverflow search.
Is this possible?
Is this possible via GitHub web GUI? How?
Is this possible via GitHub Windows GUI? How?
Is this possible via Git command prompt? How?
Reference the image below.
I don't think its possible to do this via the GUI yet but you can do this locally and push changes:
git branch -m gwt-hightchart-dashboard-demo gwt-highchart-dashboard-demo
You can just use the built in branch renaming facility to do this
git branch -m old_name new_name
Go to your repos Settings >> Options and look for "Default Branch" selection box. It will have a list of all your branches. Changing this will edit your base branch.
In my remote bare repository the HEAD is pointing to "refs/heads/master" and I want it to point to "refs/heads/other".
I am not able to go to remote repository directory and run git symbolic-ref. Is there any git command to achieve it? Or any other way?
If there is no way, does Github allow one to change the HEAD?
To change it in github, go to the admin section.
You can select the default branch from a dropdown there.
(There has been posted another question asking basically the same: How do I change a Git remote HEAD to point to something besides “master”, and there was more discussion there, with a reference to the Github group. So I'd just like to point anyone to that discussion as well.)
As we know, there is no universal answer.
But there are a specific answers for various git "farms" (where multiple users can manage git repos through a restricted interface: via http and ssh): http://Github.com, http://Gitorious.org, http://repo.or.cz, Girar (http://git.altlinux.org).
These specific answers might be useful for those reading this page and thinking about these specific services.
Now they have a drop-down menu for selecting the HEAD branch at http://repo.or.cz (example: http://repo.or.cz/editproj.cgi?name=for-me-and-for-all_imz.git);
and at http://gitorious.org, too (look somewhere in the settings);
and at http://GitHub.com: admin > Default Branch > (choose something) (thanks to #srcspider's answer);
and in Girar (running on http://git.altlinux.org to build packages for ALT's distro), one can the ssh interface for this:
$ ssh git.alt help | fgrep branch
default-branch []
$
for example ssh git.alt default-branch packages/autosshd.git sisyphus to change the HEAD in the remote repo autosshd.git to point to the sisyphus branch.