git stash apply version
2022-09-22
Question I have 2 branches: master | design Working in design I did a stash and switched to master, made some adjustments. Switched back to design and did a stash apply only to lose all my changes in the design branch. I am hoping all my work is within a stash as I have not cleared or removed these. If I do a stash list I get 4 results: stash@{0}: WIP on design: f2c0c72.…
See changes to a specific file using git
2022-09-22
Question I know that I can use the git diff command to check the changes, but, as far as I understood, it is directory based. This means it gives all the changes of all files on the current directory. How can I check only the changes in one specific file? Say, I have changed files file_1.rb, file_2.rb, ..., file_N.rb, but I am only interested in the changes in the file file_2.…
git clone with HTTPS or SSH remote?
2022-09-21
Question git clone supports both HTTPS and SSH remote URLs. Which should I use? What are the advantages of each? GitHub's docs don't make a recommendation either way. I recall in 2013 GitHub used to recommend SSH (archive link). Why was that? Answer GitHub have changed their recommendation several times (example). It appears that they currently recommend HTTPS because it is the easiest to set up on the widest range of networks and platforms, and by users who are new to all this.…
Git push requires username and password
2022-09-21
Question I cloned a Git repository from my GitHub account to my PC. I want to work with both my PC and laptop, but with one GitHub account. When I try to push to or pull from GitHub using my PC, it requires a username and password, but not when I'm using the laptop! I don't want to type my username and password every time I interact with origin. What am I missing here?…
How line ending conversions work with git core.autocrlf between different operating systems
2022-09-21
Question I've read a lot of different questions and answers on Stack Overflow as well as git documentation on how the core.autocrlf setting works. This is my understanding from what I've read: Unix and Mac OSX (pre-OSX uses CR) clients use LF line endings. Windows clients use CRLF line endings. When core.autocrlf is set to true on the client, the git repository always stores files in LF line ending format and line endings in files on the client are converted back and forth on check out / commit for clients (i.…
How to squash all git commits into one?
2022-09-21
Question How do you squash your entire repository down to the first commit? I can rebase to the first commit, but that would leave me with 2 commits. Is there a way to reference the commit before the first one? Answer As of git 1.6.2, you can use git rebase --root -i For each commit except the first, change pick to squash.
Why should I use core.autocrlf=true in Git?
2022-09-21
Question I have a Git repository that is accessed from both Windows and OS X, and that I know already contains some files with CRLF line-endings. As far as I can tell, there are two ways to deal with this: Set core.autocrlf to false everywhere, Follow the instructions here (echoed on GitHub's help pages) to convert the repository to contain only LF line-endings, and thereafter set core.autocrlf to true on Windows and input on OS X.…