Git init --bare --shared, remote, push [remotealias], fetch origin, rebase origin

# create a repo in a remote desitination with --bare
# this sets up an empty repo so that we can push into it remotely
cd [/path/to/remote/repo]
git init --bare --shared #you can leave off --shared if you want to preserve permissions
 
# add a new alias to a remote path
cd [/path/to/local/repo]
git remote add [remote alias name] [/path/to/remote/repo]
 
# push for the first time by creating the master branch 
git push [remote alias name] master #you don't have to call the branch "master"
 
#push after the first push
git push [remote alias name]
 
# to fetch changes, don't use pull, use fetch and rebase
# fetch is like add because it places changes in a staging area
git fetch origin
 
# rebase applies the changes from the master server, in this case you are rebasing from the master branch of the origin repo
git rebase origin/master
 
# you can shorten the fetch and rebase commands into one command like below
git pull --rebase

Internal References

Article Type

General