Fri, 18 Nov 2022
Git for daily use.
Updated as needed.
Download new changes and merge them:
git pull origin master
If one want to rebase rather than merge:
git pull origin master --rebase
Keep local HEAD branch and working copy files untouched:
git fetch origin
git checkout feature/test
git pull
git checkout master
git pull
git merge --no-commit test
If you want to keep a pre-defined branch topology, then you may pass --no-ff
to the git merge
command.
And then delete the feature branch:
git push -d origin feature/test # remotely
git branch -d feature/test # locally
git merge --abort
git reset --hard <last_known_good_commit>
git push -f
create the tag
git tag -a MY_TAG -m "something" -m "another line"
OR
git tag -a MY_TAG -F <comment_file>
push the tag
git push origin --tags
OR
git push origin MY_TAG
Local tag first
git tag -d <tagname>
An then remote tag
git push --delete origin <tagname>
git checkout -b <my_branch>
git reset <file>
git add history.txt
git commit --amend --no-edit
git push --force
git log -p -- <file_path>
git diff-tree --no-commit-id --name-only -r <commit id>
You can tag the tip of the branch by archiving it, and then delete the branch.
git tag archive/<branchname> <branchname>
git branch -d <branchname>
git checkout master
The branch will be deleted, and can be retrieved later by checking out the tag, and recreating the branch.
git checkout archive/<branchname>
git checkout -b new_branch_name
Or more simply :
git checkout -b new_branch_name archive/<branchname>
Do not forget to share the tag to the server
git push archive/<branchname>
or to push all your tags
git push --tags
Hard reset will lost all uncommitted and committed changes.
git fetch origin master
git reset --hard origin/master