$ git checkout -b iss53
Switched to a new branch "iss53"
This is shorthand for:
$ git branch iss53
$ git checkout iss53
# switch to branch to rename
git checkout old_branch
# rename local
git branch -m new_branch_name
# rename remote
git push origin -u new_branch_name
# delete local branch that hasn't been pushed
git branch -d branch_name
# delete old branch on remote
git push origin --delete old_branch_name
giot checkout master error: Your local changes to the following files would be overwritten by checkout:
If you want to throw away local changes, then force
git checkout -f branch
git switch remote_branch_name
list by commit date
# descending order
git branch --sort=-committerdate
# ascending order
git branch --sort=committerdate
# placed in ~/.bash_aliases
alias git-branch-last='git branch --sort=-committerdate'
# local
git for-each-ref --sort='-committerdate:iso8601' --format='%(committerdate:relative)|%(refname:short)|%(committername)' refs/heads/ | column -s '|' -t | head
# remote
git for-each-ref --sort='-committerdate:iso8601' --format='%(committerdate:relative)|%(refname:short)|%(committername)' refs/remotes/ | column -s '|' -t | head
- https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
- https://stackoverflow.com/questions/2514172/listing-each-branch-and-its-last-revisions-date-in-git/2514279#2514279
# options
git checkout origin/master fileename
git checkout master -- filename
-- differences are cached, to see differences, git diff --cached
#or (experimental - new)
git restore --source HEAD filename
# specific revision
git checkout some_hash -- fileename_1 filename_2
# commit before a revision use ~1
git checkout some_hash~1 -- fileename_1 filename_2
# commit state
git checkout some_hash
git checkout somebranch file_path
- https://stackoverflow.com/questions/13847425/overwrite-single-file-in-my-current-branch-with-the-same-file-in-the-main-branch
- https://stackoverflow.com/questions/37972753/git-reset-single-file-in-feature-branch-to-be-the-same-as-in-master
- https://stackoverflow.com/questions/215718/how-do-i-reset-or-revert-a-file-to-a-specific-revision
new command - THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
git diff --cached some_file
'--' before a file list just tells git that next args are filenamees, not anything else
after revert usee git diff --cached