FAQ

IndexTagsArchivesAbout
  • Git: Create a branch from unstaged/uncommitted changes on master

    2022-02-06

    Question Context: I'm working on master adding a simple feature. After a few minutes I realize it was not so simple and it should have been better to work into a new branch. This always happens to me and I have no idea how to switch to another branch and take all these uncommited changes with me leaving the master branch clean. I supposed git stash && git stash branch new_branch would simply accomplish that but this is what I get:…

    #git

  • How to discard local commits in Git?

    2022-02-06

    Question I'd been working on something, and decided it was completely screwed...after having committed some of it. So I tried the following sequence: git reset --hard git rebase origin git fetch git pull git checkout At which point I got the message Your branch is ahead of 'origin/master' by 2 commits. I want to discard my local commits, without having to wipe out my local directory and redownload everything. How can I accomplish that?…

    #git

  • Show which git tag you are on?

    2022-02-06

    Question I'm having trouble finding out which tag is currently checked out. When I do: git checkout tag1 git branch I can't seem to find out which tag I'm on. It only logs: * (no branch) master Is it possible to find out which tags are checked out? In the above example, this would be tag1. Answer Edit Jakub Narębski has more git-fu. The following much simpler command works perfectly:…

    #git

  • Start a Git commit message with a hashmark (#)

    2022-02-06

    Question Git treats lines starting with # (hash, number sign, octothorpe, pound sign) as comment lines when committing. This is very annoying when working with a ticket tracking system, and trying to write the ticket number at the beginning of the line, e.g. #123 salt hashed passwords Git will simply remove the line from the commit message. Is there a way to escape the hash? I tried \ and !, but nothing works.…

    #git

  • How do I add files and folders into GitHub repos?

    2022-02-05

    Question I created an account on GitHub and I'm facing a problem with adding files. I have added readme.txt. Also, I have 3 other PHP files and a folder including images. How do I add the files and folder? I tried it with git pull because git push origin -u master showed me an error. Answer You can add files using git add, example git add README, git add <folder>/*, or even git add *…

    #git

  • How to uncommit my last commit in Git [duplicate]

    2022-02-05

    Question This question already has answers here: </div> How do I undo the most recent local commits in Git? (106 answers) Closed 7 years ago. How can I uncommit my last commit in git? Is it git reset --hard HEAD or git reset --hard HEAD^ ? Answer If you aren't totally sure what you mean by "uncommit" and don't know if you want to use git reset, please see "Revert to a previous Git commit"…

    #git

  • How can I switch my git repository to a particular commit

    2022-02-04

    Question In my git repository, I made 5 commits, like below in my git log: commit 4f8b120cdafecc5144d7cdae472c36ec80315fdc Author: Michael Date: Fri Feb 4 15:26:38 2011 -0800 commit b688d46f55db1bc304f7f689a065331fc1715079 Author: Michael Date: Mon Jan 31 10:37:42 2011 -0800 commit b364f9dcec3b0d52666c4f03eb5f6efb7e1e7bda Author: Michael Date: Wed Jan 26 13:33:17 2011 -0800 commit 4771e26619b9acba3f059b491c6c6d70115e696c Author: Michael Date: Wed Jan 26 11:16:51 2011 -0800 commit 6e559cb951b9bfa14243b925c1972a1bd2586d59 Author: Michael Date: Fri Jan 21 11:42:27 2011 -0800 How can I roll back my previous 4 commits locally in a branch?…

    #git

  • «
  • 146
  • 147
  • 148
  • 149
  • 150
  • »

©2023 hugo-notepadium-mod

CC BY-NC-SA 4.0 | RSS

Powered by Hugo and the Notepadium-mod

^ TOP ^