- Commons:
git config --global http.sslVerify false
- Don't forget to use proxy!
git config --global http.proxy dm-logv:pass123@mwg:3128
git config --global https.proxy dm-logv:pass123@mwg:3128
- Don't forget to set name and email:
git config user.name "Dmitry Logvinenko"
git config user.email "5diezfun@gmail.com"
Look for a project's contribution instructions. If there are any, follow them.
- Create a personal fork of the project on Github.
- Clone the fork on your local machine. Your remote repo on Github is called
origin
.git clone https://github.com/dm-logv/matrix-python-sdk.git
- View at your remotes (there is origin only now):
git remote -v
- Add the original repository as a remote called
upstream
:git remote add upstream https://github.com/matrix-org/matrix-python-sdk.git
- View at your remotes again :)
- If you created your fork a while ago be sure to pull upstream changes into your local repository.
- Create a new branch to work on! Branch from
develop
if it exists, else frommaster
.git checkout -b proxy-support
- Implement/fix your feature, comment your code.
- Follow the code style of the project, including indentation.
- If the project has tests run them!
- Write or adapt tests as needed.
- Add or change the documentation as needed.
- Squash your commits into a single commit with git's interactive rebase. Create a new branch if necessary.
- Push your branch to your fork on Github, the remote
origin
. - From your fork open a pull request in the correct branch. Target the project's
develop
branch if there is one, else go formaster
! ...
- Once the pull request is approved and merged you can pull the changes from
upstream
to your local repo and delete your extra branch(es).
$ git merge python-impl-fixes --no-ff
$ git log --oneline --all --graph
Link: https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend
$ git push --delete origin python-impl-fixes
$ git branch -d python-impl-fixes
$ git branch -m old-name new-pretty-name
$ git push origin -u new-pretty-name
$ git push origin --delete old-name
Link: https://stackoverflow.com/a/64966/2106208
Step 1 is to show what will be deleted by using the -n option:
git clean -n
Clean Step - beware: this will delete files:
git clean -f
Link: https://stackoverflow.com/questions/2389361/undo-a-git-merge-that-hasnt-been-pushed-yet
- Reset to remote branch state:
git reset --hard origin/master
- Reset to SHA:
git reset --hard commit_sha
- Reset last commit:
git reset --hard HEAD~1
orgit reset --hard HEAD^
$ git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "dm-logv@old.email" ];
then
GIT_AUTHOR_NAME="Dmitry Logvinenko";
GIT_AUTHOR_EMAIL="5diezfun@gmail.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
# GIT_COMMITTER_DATE
# date -d '+9 hour' -R
$ git filter-branch --commit-filter '
GIT_AUTHOR_DATE
GIT_COMMITTER_DATE
git commit-tree "$@";
' HEAD
If you want to copy commits to another repository (not fork) you can make it this way:
- Add a target repo to local one:
secret-project/$ git remote add upstream https://my-pretty-git-server/my-awesome-project
- Push a branch
notes
you want to merge into the repo:secret-project/$ git checkout notes secret-project/$ git push upstream
- Let`s switch to the
my-awesome-project
and fetch a new branch:secret-project/$ cd ../my-awesome-project my-awesome-project/$ git fetch --all
- Merge it!
my-awesome-project/$ git merge --no-ff --allow-unrelated-histories notes
- Fix merge conflicts and complete a merge:
my-awesome-project/$ emacs conficted_file.cpp ... my-awesome-project/$ git merge --continue