How can I search Git branches for a file or directory?
2022-05-19
Question In Git, how could I search for a file or directory by path across a number of branches? I've written something in a branch, but I don't remember which one. Now I need to find it. Clarification: I'm looking for a file which I created on one of my branches. I'd like to find it by path, and not by its contents, as I don't remember what the contents are.…
What to do with branch after merge
2022-05-18
Question I had two branches: master and branch1. I just merged branch1 back into master and I'm done with that branch. Should I delete it or just let it sit around? Will deleting it cause any loss of data? Answer After the merge, it's safe to delete the branch: git branch -d branch1 Additionally, git will warn you (and refuse to delete the branch) if it thinks you didn't fully merge it yet.…
Creating a new empty branch for a new project
2022-05-17
Question We are using a git repository to store our project. We have our branches departing from the original branch. But now we want to create a small new project to track some documentation. For that we would want to create a new empty branch to start storing our files, and I would want other users of the network to clone that branch. How can we do that? I tried some things, but they didn't work.…
Getting Git to work with a proxy server - fails with "Request timed out"
2022-05-17
Question How do I get Git to use a proxy server? I need to check out code from a Git server, but it shows "Request timed out" every time. How do I get around this? Alternatively, how can I set a proxy server? Answer The command to use: git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080 change proxyuser to your proxy user change proxypwd to your proxy password change proxy.server.com to the URL of your proxy server change 8080 to the proxy port configured on your proxy server Note that this works for both HTTP and HTTPS repositories.…
How can I add a file to the last commit in Git? [duplicate]
2022-05-17
Question This question already has answers here: </div> How to modify existing, unpushed commit messages? (27 answers) Closed 6 years ago. Sometimes after I did a commit, I found out that I left out a file which should also be included in the commit, but was actually not. I often committed again: git add the_left_out_file git commit "include the file which should be added in the last commit" I think it might not be a good idea to do so.…
How do I make a Git commit in the past?
2022-05-17
Question I'm converting everything over to Git for my own personal use and I found some old versions of a file already in the repository. How do I commit it to the history in the correct order according the file's "date modified" so I have an accurate history of the file? I was told something like this would work: git filter-branch --env-filter="GIT_AUTHOR_DATE=... --index-filter "git commit path/to/file --date " --tag-name-filter cat -- --all Answer This is what worked for me:…
How do I push a local Git branch to master branch in the remote?
2022-05-17
Question I have a branch called develop in my local repo, and I want to make sure that when I push it to origin it's merged with the origin/master. Currently, when I push it's added to a remote develop branch. How can I do this? Answer $ git push origin develop:master or, more generally $ git push <remote> <local branch name>:<remote branch to push into>