Git revision control undo, rebase, restore, delete commit, git undo, log files, git expert help, git merge, git pull, git master, create git branch and lot more helpful git commands for enterprise grade developers.
Git Revision Control
How to undo commit on git ?
git reset –hard HEAD~1
note: its works in case yet not pushed.
Above command remove most recent commit from branch, fire again remove most recent commit again as respectively process carried. git rebase -i HEAD~N here N indicate number, 1 mean most recent 1, 2 mean most recent 2.
How to undo upto targeted commit id !
git reset –hard <sha1-commit-id>
<sha1-commit-id> give your commit-id,
How to undo all even pushed ?
git push origin HEAD –force
How to delete commits from a branch in Git ?
git reset –hard
Careful: git reset –hard WILL DELETE CHANGES OF YOUR WORKING DIRECTORY.
How to see log ?
How to commit ?
git commit -m “comment” -a
How to push to master ?
git push -u origin master
How to Search change by content ?
git log -S'<a term in the source>’
How to git push to different branch ?
This push to the same remote but a different branch
git push <branch with new changes>:<branch you are pushing to>
git push origin dev:master
This push dev branch to master branch
How to Pull from a different branch ?
git pull origin master:dev
Very helpful when new project from older or need to test other branch in our main branch
How to delete a remote branch by push ?
There is a lesser known fact that you can delete remote branches by pushing into them.
git push origin :<branch>
git branch -av # display details
push codebase :dev
git branch -av
How to pull without merge commits ?
git fetch <remotename>
How to Remove sensitive data from history, after a push ?
git filter-branch –force –index-filter ‘git rm –cached –ignore-unmatch <path-to-your-file>’ –prune-empty –tag-name-filter cat — –all && git push origin –force –all
How to Sync with remote, overwrite local changes ?
git fetch origin && git reset –hard origin/master && git clean -f -d
How to List of all files till a commit !
git ls-tree –name-only -r <commit-ish>
How to list all the conflicted files ?
git diff –name-only –diff-filter=U
How to List of all files changed in a commit ?
git diff-tree –no-commit-id –name-only -r <commit-ish>
We keep upgrade our this article for new tips.
In case you have a project with revision control and need support, feel free to contact us.
email: firstname.lastname@example.org, skype: live.snippetbucket