git remote add upstream xyz.git
git fetch upstream
git branch --set-upstream-to=upstream/master master
eller: git checkout -b test origin/test
eller: git checkout --track -b newFeature upstream/master
git merge upstream/master
eller
git rebase upstream/master
-Eventuelt merge - når ferdig: git rebase --continue
push -u -f origin branchname
git pull --rebase origin master
Git Stashi:
git stash
git stash pop
git stash list
Vise logg
git log
git log --pretty=oneline --abbrev-commit
git reset --hard # removes staged and working directory changes
NB! Forsiktig!!!
git clean -f -d # remove untracked
git clean -f -x -d # CAUTION: as above but removes ignored files like config.
git clean -fxd :/ # CAUTION: as above, but cleans untracked and ignored files through the entire repo (without :/, the operation affects only the current directory)
Go back to commit:
git revert 073791e7dd71b90daa853b2c5acc2c925f02dbc6
Soft reset (move HEAD only; neither staging nor working dir is changed):
git reset --soft 073791e7dd71b90daa853b2c5acc2c925f02dbc6
Undo latest commit:
git reset --soft HEAD~
Mixed reset (move HEAD and change staging to match repo; does not affect working dir):
git reset --mixed 073791e7dd71b90daa853b2c5acc2c925f02dbc6
Hard reset (move HEAD and change staging dir and working dir to match repo):
git reset --hard 073791e7dd71b90daa853b2c5acc2c925f02dbc6
git config --global credential.helper wincred
Opprett prosjekt
-Git init
Legge til alle filer
Git add .
Commit
Git commit - "kommentar"
Sette opp ssh keys
Ssh -keygen -t rsa -C "email"
Ssh -T [email protected] (sjekker kobling)
Sette config
git config --global user.name "Hakon Rossebo"
git config --global user.email "[email protected]
Editer config i standard editor:
git config --global --edit
-eller åpne .gitconfig i home
Lage zip arkiv
git archive --format zip --output filename.zip master
Alias til .gitconfig
[alias]
lg = log --oneline --graph --decorate
s = status
co = checkout
cob = checkout -b
bd = branch -d
aa = add .
ac = !git add . && git commit -am
ss = status -s
diffy = difftool -y
Se alle remotes
git remote -v
Legge til remote
git remote add upstream xyz.git
Fjerne remote
git remote rm origin
Vis remote branches
git branch -r
Sammenligne
git diff origin/master..master
Push branch to origin remote
git push origin -u FixtureDataImprovements
Lage en ny lokal branch som er synkronisert med remote branch
git checkout --track -b LanguageTranslations origin/LanguageTranslations
git checkout -b [branch] [remotename]/[branch]
eller
git checkout --track origin/serverfix
for å sette en eksisterende branch til å tracke en remote:
git branch -u origin/serverfix
Andre Git linker:
- https://github.com/openpnp/openpnp/wiki/Your-First-Pull-Request
- https://www.davepaquette.com/archive/2016/01/24/Submitting-Your-First-Pull-request.aspx
- http://www.firsttimersonly.com/
- http://up-for-grabs.net/#/
- https://gist.github.com/hofmannsven/6814451
- http://www.ndpsoftware.com/git-cheatsheet.html#loc=local_repo;
- https://github.com/dahlbyk/posh-git
- https://git-scm.com/book/en/v2
- https://git-scm.com/docs
- https://try.github.io/levels/1/challenges/1
- https://help.github.com/categories/bootcamp/
- https://guides.github.com/introduction/flow/
- https://mva.microsoft.com/en-US/training-courses/github-for-windows-users-16749?l=KTNeW39wC_6006218965
- https://www.webpagefx.com/blog/web-design/git-tutorials-beginners/
- https://yourfirstpr.github.io/
- http://git-school.github.io/visualizing-git