User Tools

Site Tools


programming:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
programming:git [2019/03/15 11:49] – created clemixprogramming:git [2019/12/09 14:21] (current) clemix
Line 5: Line 5:
 git push git@github.com:asmorodskyi/qatrfm-lib.git asmorodskyi-unittest:unittest git push git@github.com:asmorodskyi/qatrfm-lib.git asmorodskyi-unittest:unittest
 </code> </code>
 +
 +====== Exclude file from last commit ======
 +<code bash>
 +git reset --soft HEAD~1
 +</code>
 +Then unstage unwanted files
 +<code bash>
 +git reset HEAD path/to/unwanted_file
 +</code>
 +Now commit again, you can even re-use the same commit message:
 +<code bash>
 +git commit -c ORIG_HEAD  
 +</code>
 +====== Checkout PR from github on a new branch ======
 +<code bash>
 +#!/bin/bash +x
 +
 +pr_url="${1:?"Need 'pr_url' as parameter pointing to a github pull request or 'repo_name' (sending repo) and 'pr' variables, e.g. either 'https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/1234' 'me/os-autoinst-distri-opensuse' and '1234'"}"
 +target_repo_part=${pr_url%%/pull*}
 +pr="${pr_url##*/}"
 +pr_url=${target_repo_part/github.com/api.github.com/repos}/pulls/$pr
 +pr_content=$(curl "${AUTHENTICATED_REQUEST}" -s "$pr_url")
 +label=$(echo "$pr_content" | jq -r '.head.label') || throw_json_error "$pr_url" "$pr_content"
 +user=$(echo "$pr_content" | jq -r '.user.login') || throw_json_error "$pr_url" "$pr_content"
 +repo_name="${repo_name:-"${label%:*}/${target_repo_part##*/}"}"
 +branch="${branch:-"${label##*:}"}"
 +repo="${repo:-"https://github.com/${repo_name}.git"}"
 +
 +echo "USER:   $user"
 +echo "REPO:   $repo"
 +echo "BRANCH: $branch"
 +echo "PR:     #$pr"
 +
 +
 +echo git checkout -b "PR$pr-$user-$branch" master
 +git checkout -b "PR$pr-$user-$branch" master
 +echo git pull "$repo" "$branch"
 +git pull "$repo" "$branch"
 +</code>
 +
 +
programming/git.1552646945.txt.gz · Last modified: by clemix

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki