FAQ

IndexTagsArchivesAbout
  • Why there are two ways to unstage a file in Git?

    2022-10-02

    Question Sometimes git suggests git rm --cached to unstage a file, sometimes git reset HEAD file. When should I use which? D:\code\gt2>git init Initialized empty Git repository in D:/code/gt2/.git/ D:\code\gt2>touch a D:\code\gt2>git status On branch master Initial commit Untracked files: (use “git add <file>…” to include in what will be committed) a nothing added to commit but untracked files present (use “git add” to track) D:\code\gt2>git add a D:\code\gt2>git status…

    #git

  • What is "git remote add ..." and "git push origin master"?

    2022-10-01

    Question Quite often, Git and Ruby on Rails looks like magic... such as in the first chapter of Ruby on Rails 3 Tutorial book, it talks about Git: git remote add origin git@github.com:peter/first_app.git git push origin master And it pretty much says "it just works" without saying too much about what they are and start talking about branching. Searching on the Internet shows that git remote add is to add a "…

    #git

  • Can I 'git commit' a file and ignore its content changes?

    2022-09-30

    Question Every developer on my team has their own local configuration. That configuration information is stored in a file called devtargets.rb which is used in our rake build tasks. I don't want developers to clobber each other's devtargets file, though. My first thought was to put that file in the .gitignore list so that it is not committed to git. Then I started wondering: is it possible to commit the file, but ignore changes to the file?…

    #git

  • Delete all tags from a Git repository

    2022-09-30

    Question I want to delete all the tags from a Git repository. How can I do that? Using git tag -d tagname delete the tag tagname locally, and using git push --tags I update the tags on the git provider. I tried: git tag -d * But I see that * means the files from the current directory. $ git tag -d * error: tag 'file1' not found. error: tag 'file2' not found.…

    #git

  • How can I undo git reset --hard HEAD~1?

    2022-09-29

    Question Is it possible to undo the changes caused by the following command? If so, how? git reset --hard HEAD~1 Answer Pat Notz is correct. You can get the commit back so long as it's been within a few days. git only garbage collects after about a month or so unless you explicitly tell it to remove newer blobs. $ git init Initialized empty Git repository in .git/ $ echo “testing reset” > file1 $ git add file1 $ git commit -m ‘added file1’ Created initial commit 1a75c1d: added file1 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 file1…

    #git

  • How to merge specific files from Git branches

    2022-09-29

    Question I have 2 git branches: branch1 branch2 I want to merge all the history (multiple commits) of file.py in branch2 into file.py in branch1 and only that file. In essence I just want to work on the file.py in branch1 but want to take advantage of the merge command. What is the best way to do this? Answer When content is in file.py from branch2 that is no longer applies to branch1, it requires picking some changes and leaving others.…

    #git

  • Do I commit the package-lock.json file created by npm 5?

    2022-09-28

    Question npm 5 was released today and one of the new features include deterministic installs with the creation of a package-lock.json file. Is this file supposed to be kept in source control? I'm assuming it's similar to yarn.lock and composer.lock, both of which are supposed to be kept in source control. Answer Yes, package-lock.json is intended to be checked into source control. If you're using npm 5+, you may see this notice on the command line: created a lockfile as package-lock.…

    #node.js

  • «
  • 81
  • 82
  • 83
  • 84
  • 85
  • »

©2023 hugo-notepadium-mod

CC BY-NC-SA 4.0 | RSS

Powered by Hugo and the Notepadium-mod

^ TOP ^