Skip to content

Instantly share code, notes, and snippets.

@jltrem
Last active February 16, 2018 16:52
Show Gist options
  • Save jltrem/e07294263d6a5c1d59b426f9e646b0b2 to your computer and use it in GitHub Desktop.
Save jltrem/e07294263d6a5c1d59b426f9e646b0b2 to your computer and use it in GitHub Desktop.

##recursive add all git add --all

##commit git commit -m "this is the commit message"

##squash git reset --soft HEAD~2 && git commit where 2 is the number of commits to squash

##create branch and checkout git checkout -b branch-name

##push new branch to remote git push -u origin branch-name

##undo a file change git checkout -- thefilename

changing to multiple remotes, public and private cloud, with Azure publishing from the public cloud

/d/gitrepos/my-project/web-api (master)
$ git remote -v
origin  https://someone@bitbucket.org/project-name/web-api.git (fetch)
origin  https://someone@bitbucket.org/project-name/web-api.git (push)

/d/gitrepos/my-project/web-api (master)
$ git remote rename origin deploy

/d/gitrepos/my-project/web-api (master)
$ git remote -v
deploy  https://someone@bitbucket.org/project-name/web-api.git (fetch)
deploy  https://someone@bitbucket.org/project-name/web-api.git (push)

/d/gitrepos/my-project/web-api (master)
$ git remote add origin http://some-user@git-on-private-network.somewhere.com/foo/~some-user/my-projectline-api.git

/d/gitrepos/my-project/web-api (master)
$ git push -u origin master
Counting objects: 28, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (28/28), 5.76 KiB | 589.00 KiB/s, done.
Total 28 (delta 7), reused 0 (delta 0)
To http://git-on-private-network.somewhere.com/foo/~some-user/my-projectline-api.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

/d/gitrepos/my-project/web-api (master)
$ git remote -v
deploy  https://someone@bitbucket.org/project-name/web-api.git (fetch)
deploy  https://someone@bitbucket.org/project-name/web-api.git (push)
origin  http://some-user@git-on-private-network.somewhere.com/foo/~some-user/my-projectline-api.git (fetch)
origin  http://some-user@git-on-private-network.somewhere.com/foo/~some-user/my-projectline-api.git (push)

can then deploy git push -u deploy master to update the public cloud branch monitored by Azure

see also https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment