Git Cheat sheet
** Still a work in progress :-) **
- Git Cheat sheet
I did add the option to inputbind your Git password, but if you do not feel comfortable inputting passwords into this site I recommend copying the command into a text editor and adding it there. You can also use Github’s GUI to retrieve the SSH URL, how to do this is shown later.
Adding an existing remote to an existing project directory
Initialize a git repository in the directory
Add the git repository as origin
git remote add origin #@GITREPO@#
Set branch to master
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
Pull any files from repository (like README or LICENSE files)
Create a push-helper
Instead of using the inputbinder on this site to generate the Git URL you can also use the GUI to find the SSH url. Go to your repositories’ page and click on SSH.
Copy the link to your clipboard
sudo nano push.sh
#!/bin/bash echo "Pushing changes..." git push https://#@GITUSERNAME@#:#@GITPASSWORD@#@github.com/#@GITUSERNAME@#/#@GITREPO@#.git echo "Script finished"
push.sh file to your
echo '/push.sh' >> .gitignore
push.sh file executable
sudo chmod +x push.sh
Add changed files to staging
git add .
Commit staged files
git commit -m "Initial commit"
push.sh to push changes
If you would like to use aliases for running the push command, check out my blog post about bash here.
However great using the Git command line is, there are plenty of other ways to work with the Git protocol. The, in my opinion, two greatest candidates are GitKraken (cross-platform) and SourceTree (Windows).