User Tools

Site Tools


git

Setting up a git server is as easy as this…

# On the server
cd /usr/local/share
sudo mkdir mygitrepo
sudo useradd -d /usr/local/share/mygitrepo -c "Git repo user" gituser
sudo chown gituser mygitrepo
cd mygitrepo
sudo -u gituser mkdir myrepo1
sudo -u gituser git init --bare myrepo1
sudo passwd gituser

# On the client
mkdir project1
cd project1
touch dummyfile
git init
git add dummyfile
git commit -m "Initial commit"
git remote add origin ssh://gituser@myserver/usr/local/share/mygitrepo/myrepo1
git push origin main
# Get the current branch name
git branch  # The one with the asterisk is current
git branch --show-current
git rev-parse --abbrev-ref HEAD  # For old versions which dont have "git branch"

# Merge from main to someBranch
git checkout someBranch
git merge main

# Merge from someBranch to main
git checkout main
git merge someBranch

# Set upstream branch for local branch
git push --set-upstream origin someBranch
git.txt · Last modified: by reddy

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki