Git Cheat sheet

** Still a work in progress :-) **


Git repository:
Git username:

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.

Git password:

Starter commands

Adding an existing remote to an existing project directory

Initialize a git repository in the directory

git init

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)

git pull

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.

alt text

Copy the link to your clipboard

alt text

sudo nano

  echo "Pushing changes..."
  git push
  echo "Script finished"

Add the file to your .gitignore

echo '/' >> .gitignore

Make the file executable

sudo chmod +x

Add changed files to staging

git add .

Commit staged files

git commit -m "Initial commit"

Use 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).