The lazy programmer scripts
scripts that work

Lazy basic use of git GitHub

This script works on Windows PowerShell or Linux bash, as long as you have a git binary in the path.

# let's assume you want to create a repo from scratch 

# create the git repo directory
mkdir my-awesome-repo
cd my-awesome-repo

# initiate the repo data
# the command creates a .git folder where git stores the metadata
#     for the repo
git init

# create a branch
# when you clone a repo, the default branch is usually called master
git checkout -b master

# create a dummy file
touch my-awesome-script.perl

# add the file to be tracked by git
# this file is added to the next commit
git add my-awesome-script.perl

# "git commit" aggregates all the added or removed files into a new commit
#    and adds a commit description
# if you get an error at this step, which is related to the account,
#    you need to set the following:
#     git config --global user.name "My Name"
#     git config --global user.email my-email@example.com
git commit -m "This script is awesome"

# all the commands before are related to the local part
# to progress, we need to have a git server, where we have a repo

# add a git remote: a mapping between an alias(how you want to call
#    a repo) and an uri for a repo
# the uri type can be https/git/svn
# when you clone a repo, the default remote is called origin
git remote add myrepo https://my-awesome-git-server.server/my-awesome-repo.git

# before this step, all what you did was on your local
#    operating system
# git push will upload your changes to the git server
#    defined by the remote name and to the branch you specify
# when you execute "git push", this usually means that 
#    you are executing "git push origin master"
# the repo name is "myrepo" and "master" is the branch name
git push myrepo master

That's all, folks!

Written by kami on Wednesday September 16, 2015
Permalink - Tags: git, windows, bash, cmd, powershell, linux, github

Leave a comment

comments powered by Disqus

« Lazy alias to clean Python pyc's. - Lazy Windows show stats »