sudoedit.com!

git - notes

Push new branch to remote

git checkout -b <branch>

git push -u origin <branch>

Push existing folder to new repo

cd existing_folder
git init
git remote add origin git@gitlab.com:/path/to/project.git
git add .
git commit -m "Initial commit"
git push -u origin master

Create new remote on server (non-github/gitlab)

from loacl git repo

git clone —bare my_project my_project.git
scp -r my_project.git someservername:/srv/git/my_project.git

ssh to git host

cd /srv/git/my_project
git init —bare —shared

Verify you can clone

git clone someservername:/srv/git/my_project.git 

Add new remote

git remote add origin https://github.com/user/repo.git

git pull force overwrite

git fetch --all
git reset --hard origin/master

Git tag:

git tag -a v1.2 -m “some note”
git push origin <tag name>
git checkout tag

Or

git checkout -b tag

Git change origin

git remote set-url origin git@gitlab:project/path/awesomething.git

for https:

git remote set-url origin https://gitlab.com/project/path/awesomething.git

Push existing git to gitlab

git remote rename origin old-origin
git remote add origin git@gitlab.com:path/to/project.git
git push -u origin --all
git push -u origin --tags

deal with fatal: refusing to merge unrelated histories

git pull --allow-unrelated-histories

If you found this useful please consider supporting the blog.

Fastmail

I use Fastmail to host my email for the blog. If you follow the link from this page you'll get a 10% discount and I'll get a little bit of break on my costs as well. It's a win win.


Backblaze

Backblaze is a cloud backup solution for Mac and Windows desktops. I use it on my home computers, and if you sign up using the link on this page you get a free month of service through backblaze, and so do I. If you're looking for a good backup solution give them a try!

Thanks!

Luke

#git #notes