Reverting to a specific commit based on commit id with Git? [duplicate]
2022-10-12
Question This question already has answers here: </div> How do I revert a Git repository to a previous commit? (41 answers) Closed 9 years ago. With git log, I get a list of commits that I have made so far. commit f5c5cac0033439c17ebf905d4391dc0705dbd5f1 Author: prosseek Date: Fri Sep 3 14:36:59 2010 -0500 Added and modified the files. commit c14809fafb08b9e96ff2879999ba8c807d10fb07 Author: prosseek Date: Tue Aug 31 08:59:32 2010 -0500 Just simple test for core.…
Staging Deleted files
2022-10-12
Question Say I have a file in my git repository called foo. Suppose it has been deleted with rm (not git rm). Then git status will show: Changes not staged for commit: deleted: foo How do I stage this individual file deletion? If I try: git add foo It says: 'foo' did not match any files. Update (9 years later, lol): This looks like it has been fixed in git 2.…
How to link to a specific line number on GitHub
2022-10-11
Question I know I can link to a specific line number on a file on a GitHub repository (I'm sure I've seen this before)... How can I do this? Answer Don't just link to the line numbers! Be sure to use the canonical URL too. Otherwise when that file is updated, you'll have a URL that points to the wrong lines! How to make a permanent link to the right lines:…
How to move some files from one git repo to another (not a clone), preserving history
2022-10-11
Question Our Git repositories started out as parts of a single monster SVN repository where the individual projects each had their own tree like so: project1/branches /tags /trunk project2/branches /tags /trunk Obviously, it was pretty easy to move files from one to another with svn mv. But in Git, each project is in its own repository, and today I was asked to move a subdirectory from project2 to project1. I did something like this:…
How to show uncommitted changes in Git and some Git diffs in detail
2022-10-11
Question How do I show uncommitted changes in Git? I STFW'ed, and these commands are not working: teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git status On branch teyan/psservice Your branch is up-to-date with 'origin/teyan/psservice'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: psservice.c modified: psservice.vcxproj.filters teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git diff teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git diff master fatal: ambiguous argument ‘master’: unknown revision or path not in the working tree.…
What exactly does the "u" do? "git push -u origin master" vs "git push origin master"
2022-10-11
Question I'm apparently terrible at using git, despite my best attempts to understand it. From kernel.org for git push: -u --set-upstream For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch.<name>.merge in git-config(1). Here's branch.<name>.merge from git config: branch.<name>.merge Defines, together with branch.<name>.remote, the upstream branch for the given branch. It tells git fetch/git pull which branch to merge and can also affect git push (see push.…
What is the precise meaning of "ours" and "theirs" in git?
2022-10-11
Question This might sound like too basic of a question, but I have searched for answers and I am more confused now than before. What does "ours" and "theirs" mean in git when merging my branch into my other branch? Both branches are "ours". In a merge conflict is "ours" always the upper of the two versions displayed? Does "ours" always refer to the branch that HEAD was pointing to when the merge began?…