Last active
December 20, 2015 17:59
-
-
Save daniel-fanjul-alcuten/6172908 to your computer and use it in GitHub Desktop.
to run automatically before I login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| cd ~ | |
| hostname=$(hostname -f) | |
| if ! [ -d .git ]; then | |
| git init | |
| git remote add origin git@ghe.spotify.net:dfanjul/dotfiles.git | |
| else | |
| git remote set-url origin git@ghe.spotify.net:dfanjul/dotfiles.git | |
| fi | |
| branch=$hostname | |
| branch_ref=refs/heads/$branch | |
| tracking_branch_ref=refs/remotes/origin/$branch | |
| tracking_master_ref=refs/remotes/origin/master | |
| branch_ref_in_remote=refs/heads/$branch | |
| if ! git show-ref -q --verify $branch_ref; then | |
| git fetch -v origin | |
| if ! git show-ref -q --verify $tracking_branch_ref; then | |
| git push origin $tracking_master_ref:$branch_ref_in_remote | |
| fi | |
| git checkout -f -b $branch -t $tracking_branch_ref | |
| fi | |
| git pull --ff-only | |
| ~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment