FAQ

IndexTagsArchivesAbout
  • How can I calculate the number of lines changed between two commits in Git?

    2022-04-23

    Question Is there any easy way to calculate the number of lines changed between two commits in Git? I know I can do a git diff, and count the lines, but this seems tedious. I'd also like to know how I can do this, including only my own commits in the line counts. Answer You want the --stat option of git diff, or if you're looking to parse this in a script, the --numstat option.…

    #git

  • Which characters are illegal within a branch name?

    2022-04-23

    Question Which characters are illegal within a branch name? Answer Naming rules for refname: Git imposes the following rules on how references are named: They can include slash / for hierarchical (directory) grouping, but no slash-separated component can begin with a dot . or end with the sequence .lock. They must contain at least one /. This enforces the presence of a category like heads/, tags/ etc. but the actual names are not restricted.…

    #git

  • How and/or why is merging in Git better than in SVN?

    2022-04-22

    Question I've heard in a few places that one of the main reasons why distributed version control systems shine, is much better merging than in traditional tools like SVN. Is this actually due to inherent differences in how the two systems work, or do specific DVCS implementations like Git/Mercurial just have cleverer merging algorithms than SVN? Answer The claim of why merging is better in a DVCS than in Subversion was largely based on how branching and merge worked in Subversion a while ago.…

    #svn

  • How to grep (search) committed code in the Git history

    2022-04-22

    Question I have deleted a file or some code in a file sometime in the past. Can I grep in the content (not in the commit messages)? A very poor solution is to grep the log: git log -p | grep <pattern> However, this doesn't return the commit hash straight away. I played around with git grep to no avail. Answer To search for commit content (i.e., actual lines of source, as opposed to commit messages and the like), you need to do:…

    #git

  • Undo a particular commit in Git that's been pushed to remote repos

    2022-04-22

    Question What is the simplest way to undo a particular commit that is: not in the head or HEAD Has been pushed to the remote. Because if it is not the latest commit, git reset HEAD doesn't work. And because it has been pushed to a remote, git rebase -i and git rebase --onto will cause some problem in the remotes. More so, I don't want to modify the history really.…

    #git

  • git - remote add origin vs remote set-url origin

    2022-04-21

    Question I create a new repository: git init echo "# MESSAGE" >> README.md git add README.md git commit -m "first commit" Then I want to push my commit to the empty remote repository created on github so I have to set remote. What is difference between using following commands ? : git remote add origin git@github.com:User/UserRepo.git git remote set-url origin git@github.com:User/UserRepo.git At the end I perform push: git push -u origin master What happens when I call git remote set-url origin just after git init?…

    #git

  • What is the difference between origin and upstream on GitHub?

    2022-04-21

    Question What is the difference between origin and upstream on GitHub? When a git branch -a command is executed, some branches it displays have a prefix of origin (remotes/origin/..) while others have a prefix of upstream (remotes/upstream/..). Answer This should be understood in the context of GitHub forks (where you fork a GitHub repo on GitHub before cloning that fork locally). upstream generally refers to the original repo that you have forked (see also "…

    #git

  • «
  • 121
  • 122
  • 123
  • 124
  • 125
  • »

©2023 hugo-notepadium-mod

CC BY-NC-SA 4.0 | RSS

Powered by Hugo and the Notepadium-mod

^ TOP ^