Categories
Git

Git Branch update with new code

These commands are useful for the following scenario:

Created branch mergeTypeDefs

build code and checked in

Created branch mergeResolvers using code checked out from mergeTypeDefs

went back to mergeTypeDefs and updated the code.

to update the mergeResolvers branch, the following commands were required:

git checkout mergeResolvers
git merge mergeTypeDefs
Categories
Git

Add ssh key to git. how to set up

git remote set-url origin git@github.com:username/your-repository.git

Categories
Git

initial post for using main

echo "# udacity-controlled2" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/mclark610/udacity-controlled2.git
git push -u origin main
Categories
Git

Git change branch name

Very cool.  I created a branch to work on one feature and did something completely different. Going to rename branch and and blow away branch on remote


git branch -m old_branch new_branch         # Rename branch locally    

git push origin :old_branch                 # Delete the old branch    

git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote

Thanks to https://www.w3docs.com/snippets/git/how-to-rename-git-local-and-remote-branches.html for this one!

Categories
Git

GIT

Important git commands used more often
Committing files to wrong branch – in this case: master

git reset HEAD~
git commit -c ORIG_HEAD

Adding version number(tag) to commit

git tag -a "v1.0.0-beta"

List version numbers used

local: git tag --list
remote: git ls-remote --tags 

Push tags to remote

git push --tags

status including neat branch graph

git status
git log --graph

push branch to local and remote

git checkout -b new_branch_name
git commit -m "new branch"
git push -u origin new_branch_name
Categories
Git

Git

git – switch branches


git -b mybranch (-b creates a new branch)