$ git config -l
Configure user name and email - either per repository or global.
Repository configuration for a GitHub project:
$ git config user.name Matze2
$ git config user.email 12542802+Matze2@users.noreply.github.com
Use rebase instead of merge for pull.
$ git config --global branch.autosetuprebase always
Allow rebasing with uncomitted changes
$ git config --global rebase.autoStash true
$ git status
$ git add dir1/file1
$ git add *.java
$ git add .
$ git reset HEAD dir1/file1
$ git rm --cached dir1/file1
$ git show [commit-reference]
$ git checkout file
$ git commit --amend -m "More changes - now correct"
From the remote fork:
$ git clone https://github.com/Matze2/cgeo.git
Show remote repositories configured for the local repository:
$ git remote -v
The remote repository "upstream" is usually an official GitHub repository
$ git remote add upstream https://github.com/cgeo/cgeo.git
The remote repository "origin" is usually the own fork of an official GitHub project.
$ git remote add origin https://github.com/Matze2/cgeo.git
https://help.github.com/articles/syncing-a-fork/
$ git checkout master
$ git fetch upstream
$ git merge upstream/master
or better
$ git rebase upstream/master
You might also want to update the fork repository on github
$ git push -f origin master
TODO: Unterschied zwischen merge und pull????
$ git rebase master
Which local branches are available in this repository:
$ git branch
Which remote and local branches are available in this repository with details:
$ git branch -av
Between master and feature branch:
$ git diff master 6848_result_highlighting
Shows the diff between the current state of these two branches of the branch when it was forked off master.
$ git diff master..6848_result_highlighting
$ git diff master...6848_result_highlighting
Shows the changes of the branch when it was forked off master.
$ git branch <issue_id>_description
$ git checkout <issue_id>_description
Rename the branch (when you are in it)
$ git branch -m <new name>
Delete a branch
$ git branch -D <branch name>
Do your implementation in this branch and commit your changes from time to time.
$ git commit -a
A commit log which automatically would close the corresponding issue:
Fix #<issue_id> description
$ git fetch origin
$ git rebase origin/master
$ git push -u origin 6851_copy_waypoint_notes
Passwords are saved in kwallet, section kssaskpass:
- https://github.com -> Matze2
- https://Matze2@github.com -> Passwort
After that it is enough to just push or force-push (e.g. if the commits are pushed and should be squashed):
$ git push
$ git push -f
Commit local changes as before:
$ git commit -a
and push it.
If you want to change commit logs or squash single commits together an interactive rebase is needed. To interactively rebase the last n commits use
$ git rebase -i HEAD~n
Alternatively, you can find the commit that is base of your branch by running
$ git merge-base my-branch edx/master
This will return a commit hash which can be used as argument to the rebase command above.
To rename a commit log mark the commit entries with "r(eword)". Mark commits that should be squashed with "s(quash)".
After saving another editor opens to change the commit logs or to choose the common commit comment.
Interactively rebased changes can be pushed to the pull request branch with force flag.
https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request
https://help.github.com/articles/checking-out-pull-requests-locally/
$ git checkout master
$ git fetch origin pull/6848/head:6848_result_highlighting
A new branch 6848_result_highlighting is created with the PR changes.
$ git branch mybranch
$ git checkout mybranch
$ git pull upstream pull/6836/head
$ git pull upstream pull/6848/head
$ git pull origin 6851_copy_waypoint_notes
Define a remote for the other user's repository.
$ git remote add other_user https://github.com/other_user/cgeo.git
$ git fetch other_user
$ git branch other_users_branch
$ git checkout other_users_branch
Check history of other_user's branch and pull the changes.
$ git log other_user/other_users_branch
$ git pull other_user other_users_branch
$ git log