FAQ

IndexTagsArchivesAbout
  • How do I find and restore a deleted file in a Git repository?

    2022-06-30

    Question Say I'm in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I discover that I need to restore that file after deleting it. I know I can checkout a file using git checkout <commit> -- filename.txt, but I don't know when that file was deleted. How do I find the commit that deleted a given filename? How do I restore that file back into my working copy?…

    #git

  • How to revert a "git rm -r ."?

    2022-06-30

    Question I accidentely said git rm -r .. How do I recover from this? I did not commit. I think all files were marked for deletion and were also physically removed from my local checkout. EDIT: I could (if I knew the command) revert to the last commit. But it would be a lot better if I could just undo the git rm -r .. Because I am not really sure what I did after the last commit and before the git rm -r .…

    #git

  • How do I delete a Git branch locally and remotely?

    2022-06-29

    Question Failed Attempts to Delete a Remote Branch: $ git branch -d remotes/origin/bugfix error: branch 'remotes/origin/bugfix' not found. $ git branch -d origin/bugfix error: branch ‘origin/bugfix’ not found. $ git branch -rd origin/bugfix Deleted remote branch origin/bugfix (was 2a14ef7). $ git push Everything up-to-date $ git pull From github.com:gituser/gitproject [new branch] bugfix -> origin/bugfix Already up-to-date. How do I properly delete the remotes/origin/bugfix branch both locally and remotely? Answer Executive Summary git push -d <remote_name> <branchname> git branch -d <branchname> Note: In most cases, <remote_name> will be origin.…

    #git

  • Why is Github asking for username/password when following the instructions on screen and pushing a new repo?

    2022-06-29

    Question I'm the owner of an organization on github and just created a repo and tried pushing but I'm running into an issue where it's asking me for my username even though I can SSH just fine: $ ssh -T git@github.com Hi Celc! You've successfully authenticated, but GitHub does not provide shell access. $ git add . $ git commit -m 'first commit' [master (root-commit) 3f1b963] first commit 6 files changed, 59 insertions(+) create mode 100644 .…

    #git

  • How to diff one file to an arbitrary version in Git?

    2022-06-27

    Question How can I diff a file, say pom.xml, from the master branch to an arbitrary older version in Git? Answer You can do: git diff master~20:pom.xml pom.xml ... to compare your current pom.xml to the one from master 20 revisions ago through the first parent. You can replace master~20, of course, with the object name (SHA1sum) of a commit or any of the many other ways of specifying a revision.…

    #git

  • What is git tag, How to create tags & How to checkout git remote tag(s)

    2022-06-27

    Question when I checkout remote git tag use command like this: git checkout -b local_branch_name origin/remote_tag_name I got error like this: error: pathspec origin/remote_tag_name did not match any file(s) known to git. I can find remote_tag_name when I use git tag command. Answer Let's start by explaining what a tag in git is A tag is used to label and mark a specific commit in the history. It is usually used to mark release points (eg.…

    #git

  • Create a branch in Git from another branch

    2022-06-26

    Question I have two branches: master and dev I want to create a "feature branch" from the dev branch. Currently on the branch dev, I do: git checkout -b myfeature dev ... (some work) git commit -am "blablabla" git push origin myfeature But, after visualizing my branches, I got: --**master** ------0-----0-----0-----0-----0 ------------------------**dev**----**myfeature** I mean that the branch seems fast-forward merged, and I don't understand why... What am I doing wrong?…

    #git

  • «
  • 106
  • 107
  • 108
  • 109
  • 110
  • »

©2023 hugo-notepadium-mod

CC BY-NC-SA 4.0 | RSS

Powered by Hugo and the Notepadium-mod

^ TOP ^