-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-dropbox.sh
More file actions
executable file
·48 lines (39 loc) · 1.45 KB
/
git-dropbox.sh
File metadata and controls
executable file
·48 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Script by Li Richard, I made a little changes.
# https://github.com/othercat/MyUtilities/blob/master/OSXShellCommands/git-dropbox.sh
# Creates git projects for file folders by making the origin Dropbox. You will need to install Dropbox for this to work.
# Reference URL is http://stackoverflow.com/questions/1960799/using-gitdropbox-together-effectively
ProjectPath=$(pwd)
ProjectName=$(basename $ProjectPath)
GIT=/usr/local/bin/git
#Please notice that if use "~" as path you should use $HOME instead
DropboxPath="$HOME/Dropbox/git"
echo "## ${ProjectName} is on your Dropbox! Edit me to describe this repo." > README.md;
# Enable git with this project.
if [ -s '.git' ] ; then
echo " $ProjectName is already a git repository, ignoring..."
else
echo " Initializing git for $ProjectName..."
git init -q
git add .
git commit -m "Initial commit to Dropbox." -q
# Make the origin Dropbox.
echo " Putting $ProjectName project on Dropbox..."
if [ ! -d $DropboxPath ]; then
mkdir -p $DropboxPath
fi
cd $DropboxPath
# if [ ! -d ${DropboxPath}/git ]; then
# mkdir git
# fi
# cd git
mkdir ${ProjectName}.git
cd ${ProjectName}.git
git init -q --bare
# Link the project to the origin
echo " Copying local $ProjectName to Dropbox..."
cd $ProjectPath
git remote add origin ${DropboxPath}/${ProjectName}.git
git push -q --set-upstream origin master
#git branch --set-upstream master origin/master
fi