Git - What is the difference between push.default "matching" and "simple"
2022-06-26
Question I have been using git for a while now, but I have never had to set up a new remote repo myself and I have been curious on doing so. I have been reading tutorials and I am confused on how to get "git push" to work. If I simply use git push it asks me to see up a default branch(?) to point to? What is the difference between these two options it supplies me with?…
How does Git handle symbolic links?
2022-06-26
Question If I have a file or directory that is a symbolic link and I commit it to a Git repository, what happens to it? I would assume that it leaves it as a symbolic link until the file is deleted and then if you pull the file back from an old version it just creates a normal file. What does it do when I delete the file it references? Does it just commit the dangling link?…
Reset all changes after last commit in git
2022-06-26
Question How can I undo every change made to my directory after the last commit, including deleting added files, resetting modified files, and adding back deleted files? Answer First, reset any changes This will undo any changes you've made to tracked files and restore deleted files: git reset HEAD --hard Second, remove new files This will delete any new files that were added since the last commit: git clean -fd Files that are not tracked due to .…
git reset --hard HEAD leaves untracked files behind
2022-06-25
Question When I run git reset --hard HEAD, it's supposed to reset to a pristine version of what you pulled, as I understand it. Unfortunately, it leaves files lying around, as a git status shows a big list of untracked files. How do you tell git "Just bring it back to EXACTLY what was in the last pull, nothing more, nothing less"? Answer You have to use git clean -f -d to get rid of untracked files and directories in your working copy.…
Partly cherry-picking a commit with Git
2022-06-25
Question I'm working on 2 different branches: release and development. I noticed I still need to integrate some changes that were committed to the release branch back into the development branch. The problem is I don't need all of the commit, only some hunks in certain files, so a simple git cherry-pick bc66559 does not do the trick. When I do a git show bc66559 I can see the diff but don't really know a good way of applying that partially to my current working tree.…
Creating folders inside a GitHub repository without using Git
2022-06-24
Question I want to add a new folder to my newly created GitHub repository without installing the Git setup for (Mac, Linux, and Windows). Is it possible to do so? I can't have Git all the time with me when I work on different systems/machines. I know how to add files directly in a repository on github.com/[USER]/[REPO]. Can we create a folder as well? Answer After searching a lot I find out that it is possible to create a new folder from the web interface, but it would require you to have at least one file within the folder when creating it.…
Showing which files have changed between two revisions
2022-06-24
Question I want to merge two branches that have been separated for a while and wanted to know which files have been modified. Came across this link: http://linux.yyz.us/git-howto.html (moved to web.archive.org) which was quite useful. The tools to compare branches I've come across are: git diff master..branch git log master..branch git shortlog master..branch Was wondering if there's something like "git status master..branch" to only see those files that are different between the two branches.…