cd ~/github
mkdir <repo_dir>
cd <repo_dir>
git init
git clone <repo_URL>
git clone [email protected]:ksferguson/<repo>.git
(or clone from github.com web page)
git add <new_file>.txt
git add --all
git commit -m "added <new_file>.txt to the repo"
git remote add <remote_name> <remote_repo_url>
git pull <remote> <branch>
git push -u <remote_name> <local_branch_name>
git commit -m "added changes to fix xyz"
git push origin master
#Lists all local branches in the current repository
git branch
#Creates a new branch
git branch [branch-name]
#Switches to the specified branch and updates the working directory
git checkout [branch-name]
git merge [branch]
I wanted a copy of my gists in my local repo in case I'm unconnected and need one of my cheats, so I setup as follows to avoid having to copy and paste the long names for each gist.
- clone each gist repo into ~/github/gists/ folder (grab clone link from each gist page)
- create three shell commands to iterate over the long meaningless repo names
bash check-gists.sh
bash push-gists.sh
bash pull-gists.sh
check-gists.sh
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && echo '{}' && git status" \;
push-gists.sh
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && echo '{}' && git push origin master" \;
pull-gists.sh
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && echo '{}' && git pull" \;
git config --global user.name <yourusername>
git config --global user.email <yourgithubemail>
git config --system core.editor <editor>
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.up rebase
git config --global alias.ci commit