Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Aphorismen
Applications
Business Economics & Admin.
My Computers
Cooking
Devices
Folders
Food
Hardware
Infos
Software Development
Sports
Operation Instructions
Todos
Test
Help
Glossary
Community portal
adaptions
Sidebar anpassen
Wiki RB4
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Git
(section)
Page
Discussion
English
Read
Edit
View history
Toolbox
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Manage Branches=== ====Show Branches==== Currently checked-out branch has an asterik in front of the output: git branch // show all local branches git branch --merged [--no-merged] // show all local branches which are merged into the current branch (those w/o asterik could be deleted) git branch --no-merged // show all local branches which are not merged into the current branch git branch -r // shows only remote branches git branch -a // shows all branches (local, tracking and remote) git branch -vv // shows tracking information for local branches in the form: // <BRANCH_NAME> <SHA-1> [<REMOTE BRANCH>: ahead and behind comparison] <LAST_COMMIT_MESSAGE> git remote show origin // full picture about tracked branches and status ====Checkout a branch==== Checkout will not override changed files but will be aborted and show a warning: git checkout <BRANCH_NAME> // in new git versions it will if the the branch does not exist locally get the remote one (-t) git checkout -b <BRANCH_NAME> // creates a branch and checks it out, short of git branch <BRANCH_NAME> and git checkout <BRANCH_NAME> git checkout --track origin/<BRANCH_NAME> // create a local branch based on remote branch and checks it out git checkout -t origin/<BRANCH_NAME> // s.a. ====Merge Branches==== A merge of a branch into the master branch (s. [https://git-scm.com/book/de/v1/Git-Branching-Einfaches-Branching-und-Merging here]): git merge <BRANCHNAME> // <BRANCHNAME> => <CURRENT_BRANCH>, checkout the branch in which the merge should be performed before git checkout master git merge origin/master git checkout Branch1 git merge master // merge master into Branch1 ====Compare Branches==== git diff <BRANCH> <BRANCH> [--name-only] // e.g. git diff Branch1 master git diff master origin/master // compare local with remote branch, output for each file is diff --git <FILE VERSION A> <FILE VERSION B> ... --- <FILE VERSION A> +++ <FILE VERSION B> - <CONTENT FILE A> + <CONTENT FILE B> ====Track a branch==== git branch -u origin/<BRANCH_NAME> // sets the remote branch as upstream branch git checkout -b <NEW_BRANCH_NAME> <REMOTE>/<REMOTE_BRANCH_NAME> // creates a new branch as tracking branch git checkout --track <REMOTE>/<REMOTE_BRANCH_NAME> // does the same ====Delete a branch==== git branch -d <BRANCH_NAME> // deletes a local branch, but only if it was fully merged before, otherwise use -D option git branch -D <BRANCH_NAME> // deletes a local branch, regardless whether it has been merged before git push origin :<BRANCH_NAME> // delete a remote branch
Summary:
Please note that all contributions to Wiki RB4 may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Uwe Heuer Wiki New:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width