- Reverting changes to modified files
git reset --hard
- Removing a remote branch
git push origin --delete my-branch
Creating A New Remote For A Local Repo
This process is used when:
- You have code on your local machine that is in a git repo.
- This code is not currently pushed to a remote.
- You want to store a remote on a different filesystem (e.g. a directory accessible over NFS or SSH).
In this example I’m pushing to a shared Windows drive.
# Navigate to the location of where you want to store your code. cd \\some-server\share$\tom\git git init --bare dotemacs # Now navigate to your repo and push cd c:\users\tom\.emacs git remote add origin '\\some-server\share$\tom\git\dotemacs' git push --set-upstream origin master git push origin --mirror
Now you can backup your repo to a different server and even share your code with others who have access to that shared directory.
- This is a very long line this is a very long line this is a very long line this is a
View Pull Request Diff From The Command Line
cd $project git checkout $trunk git pull git checkout $feature_branch git pull git request-pull dev ./ # If you want to see the diff contents add the -b flag
Convincing Git That a File Isn’t Binary
I have an issue occasionally where
git thinks that some of my text files are
binary. Specifically, this seems to happen frequently with my
files. Here’s what I’ve done to fix this.
Please note that this process still seems a bit black-magicky to me. Some of these steps may not be necessary.
- In my repository, create a
.gitattributesfiles with the following contents:
*.txt text working-tree-encoding=UTF-16LE eol=CRLF
- I chose this text encoding because it appears to be the default on my Windows laptop running emacs.
- I set the encoding of my file to
utf-8-dosin Emacs and saved it.
- Commit both files to the
- Make another change to the target text file (e.g.
You should now be able to perform a “text” diff on your files.