Here's a few things I might find my future self forgetting again.
If I'm a dummy and forgot to save my ssh keys:
ssh-keygen -t rsa -b 4096 -C 'foo@bar.com'If I want to put a local repository on GitHub, the first step is to create an empty repository on GitHub, and then, at the top level of my local repository, run:
git remote add origin git@github.com:AssumeACanOpener/some_project.gitBe sure to go with ssh and not https, unless you like typing usernames and passwords all the time.
On your initial push to GitHub do:
git push -u origin masterOtherwise a pull is going to say you're not up to date, even though you are really.
In the past when I accidentally tracked files, I'd imagine I've probably just copied something, did a git rm, and then moved whatever it was back. But there's a better way. If you've accidentally added a file to version control, but you don't want to delete it and simply take it out of version control:
git rm --cached file.txtPut file names you don't want to track into a .gitignore file at the top level of your repository. Funnily enough, you need to add .gitignore to the .gitignore file.
To check what files are currently under version control:
git ls-tree -r master --name-onlyIf you've forked something from github and still want to follow upstream changes, you'll need to add the upstream repository to your fork. For example:
git remote add upstream https://github.com/gregmalcolm/python_koans.gitThen, to update:
git pull upstream masterAnd if I ever forget the init, add, status, and commit commands, I need to pack it up and go home.
No comments:
Post a Comment