Mindblown: a blog about philosophy.
-
How to Delete Branch in GIT
Switch to some other branch first git checkout <some-other-branch-name> Delete remote branch git push origin –delete <branch_name> Delete local branch now (This command will fail, if there is any pending work to be committed / merged) git branch -d <branch-name-to-delete> Delete local branch forcefully irrespective of merge status git branch -D <branch-name-to-delete> OR git branch…
-
How to Create Branch in GIT
Create a blank branch (no-switching) git branch <branch-name> Create a blank branch and switch to it git checkout -b <branch-name> Create a branch from other branch git checkout -b <branch-name> <branch-name-from>
-
How to Merge in GIT
register modified and untracked files git add <files-to-add> Commit changes git commit -m “commit message” pull changes from origin git pull –rebase In case, merge conflict appears git mergetool –tool=opendiff Once merge is complete, save file and complete rebasing git rebase –continue Push finally git push resolve behind revisions Checkout to local-branch git checkout <local-branch>…
-
How to Commit in GIT
Commit code (make sure to add files first which need to be committed) git commit -m <message> Commit code to previous commit git commit –amend E.g. git commit -m ‘sample commit’ git add forgotten-file git commit –amend Undo Add git reset Undo Commit Undo git commit (changes get unstaged i.e. after modification, we need to…
-
What is Stash in GIT
Clear stash list git stash clear Show all stashes git stash list Drop a stash Removes latest stash git stash drop Removes given stash name git stash drop <name-of-stash-to-drop>
-
How to do Undo things done mistakenly in GIT
Remove file added to staging for commit Undo git add command git checkout — <filename> Discard Changes to added file to staging git checkout <filename>; i.e. checkout repository’s version Undo last commit git reset –soft HEAD^ *This command would undo commit, but would keep changes so that we can re-modify and re-commit Undoing GIT Merge…
-
How to Moving files in GIT
git mv <file1> <file2>
-
How to rename files from GIT
git mv <file1> <file2>
-
How to know the status of files Addition and Deletion in GIT
Status git status -s
-
How to Delete files from staging area
Delete files from staging area, local machine, and remote repository git rm <file-name> commit now to make changes reflected in local, staging and remote-repository
Got any book recommendations?