https://www.git-tower.com/blog/git-cheat-sheet/

https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html

Start

git clone git@git.example.com:project.git

 

Get the branch

git checkout branch1
git pull

 

Create new branch from current

git checkout -b temporary-branch
git branch

 

Submit changes to branch

git add somechangedfiles
git commit -m "add some fix to somechangedfiles"
git push origin temporary-branch

Commit with auto add

git commit -a -m "fix something in couple of files"

 

Get updates from source branch to your current

git pull origin master
git push origin temporary-branch

Remove temporary branch

git checkout master
git push origin :temporary-branch
git branch -d temporary-branch
git branch -D temporary-branch

Change commited

Squash commits

not published

git log
git rebase --interactive
#pick 02bbcc5 update1
#squash 22ee95e update2
#squash 1dcc468 update3

published

git rebase --interactive origin/temporary-branch~4 temporary-branch
git push origin +temporary-branch

Discard all uncommitted changes

git checkout -f

Remove last commit

git reset --soft HEAD~1

Restore uncommitted file

git checkout filename


Cherry-pick

 

git checkout source-branch
git log
git checkout destination-branch
git cherry-pick <commit-hash>
git push origin destination-branch
  • No labels