Skip to content

Instantly share code, notes, and snippets.

@Elmuti
Created January 1, 2024 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elmuti/d0c4ec613464f3ae7b6dfe8076c5167c to your computer and use it in GitHub Desktop.
Save Elmuti/d0c4ec613464f3ae7b6dfe8076c5167c to your computer and use it in GitHub Desktop.

clone a new repo as local

git clone repourl

create a new repo from local

  • create repo on github/gitlab etc, then:
git init
git remote add repourl

create a new branch

git checkout -b branchname

if you have unstaged changes, these changes will follow you to the new branch

swap to a branch

git checkout branchname

get local branch up to date with changes to master

git commit (if you have unstaged changes)
git checkout master
git pull origin master
git checkout branchname
git rebase master

get changes from branch2 to yours

git commit (if you have unstaged changes)
git checkout branch2name
git pull origin branch2name
git checkout branchname
git rebase branch2name

i am on a feature branch and want to push select files

git status
git add filename
git add filename2
git commit -m "commit message here"
git push origin featurebranchname

i am on a feature branch and want to push everything

git status
git add .
git commit -m "commit message here"
git push origin featurebranchname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment