Ubuntus
How to resolve git stash conflict without commit?
2023-08-08
Question As asked in this question, I also want to know how to resolve a conflicting git stash pop without adding all modifications to a commit (just like "git stash pop" without a conflict does). My current approach is very uncool because I do it this way: git stash pop # -> CONFLICT git stash drop # [resolve conflict] # [add conflict files] git reset HEAD # <all files that are in commit-mode> How to reproduce:…
git mv and only change case of directory
2023-08-07
Question While I found similar question I didn't find an answer to my problem When I try to rename the directory from FOO to foo via git mv FOO foo I get fatal: renaming 'FOO' failed: Invalid argument OK. So I try git mv FOO foo2 && git mv foo2 foo But when I try to commit via git commit . I get # On branch master # Untracked files: # (use "…
How do I rename both a Git local and remote branch name?
2023-08-07
Question I have a local branch master that points to a remote branch origin/regacy (oops, typo!). How do I rename the remote branch to origin/legacy or origin/master? I tried: git remote rename regacy legacy But this gave an error: error : Could not rename config section 'remote.regacy' to 'remote.legacy' Answer There are a few ways to accomplish that: Change your local branch and then push your changes Push the branch to remote with the new name while keeping the original name locally Renaming local and remote # Rename the local branch to the new name git branch -m <old_name> <new_name> Delete the old branch on remote - where <remote> is, for example, origin git push <remote> –delete <old_name>…
How to use git to get just the latest revision of a project?
2023-08-07
Question I don't want to clone the full repository and I'm not going to be submitting patches. I do want to easily get new revisions in the future. I have tried using git clone, but this creates a copy of the entire repository (huge file size) and tracking changes makes the disk space even bigger (100mb of files now takes up over 2gb). Is this possible? Answer Use git clone with the --depth option set to 1 to create a shallow clone with a history truncated to the latest commit.…
Export a stash to another computer
2023-08-06
Question I need a way to export a stashed change to another computer. On computer 1 I did $ git stash save feature I'm trying to get the stash patch to a file and then import it to another computer $ git stash show -p > patch This command gives me a file that I can move to another computer where this repo is cloned, but the question is how to import it as a stash again.…
How can I view a git log of just one user's commits?
2023-08-06
Question When using git log, how can I filter by user so that I see only commits from that user? Answer This works for both git log and gitk - the 2 most common ways of viewing history. You don't need to use the whole name: git log --author="Jon" will match a commit made by "Jonathan Smith" git log --author=Jon and git log --author=Smith would also work. The quotes are optional if you don't need any spaces.…
How to make git mark a deleted and a new file as a file move?
2023-08-06
Question I've moved a file manually and then I've modified it. According to Git, it is a new file and a removed file. Is there any way to force Git into treating it as a file move? Answer Git will automatically detect the move/rename if your modification is not too severe. Just git add the new file, and git rm the old file. git status will then show whether it has detected the rename.…