Basic GIT commands
1. Merge sandeepnew branch to dev-new branch
git checkout dev-newgit pull origin dev-new
git merge sandeepnew
git push origin dev-new
2. Resolve a conflict
Manually remove headgit add <filename>
git commit <filename> -m "commit message"
git push
3. Create a new branch with existing branch (xyz)
git checkout xyz //go to xyz branchgit checkout -b <new branch name>
git push origin <new branch name>
4. Delete a branch
//delete local branch
git branch -d <branch name>//delete remote branch
git push origin --delete <branch name>
5. Force delete a branch
git branch -D <branch name>6. Revert to some previous commit
git revert <commit ID>git commit -am "rever back"
git push origin master
###### Another way ######
git reset --hard <commit ID>
git push -f origin master
7. Git cherry pick will be used to pick some commits
8. you need to resolve your current index [error solved] (this will reset branch to before merging states)
git reset --merge9. Reset sub module (submodule conflict error)=> go to sub module and run below command
git reset HEAD subby10. Cloning remote branch to local branch
git clone git@github.com:Timescity/TcModels.git11. Get sub branchs
git checkout -b branchname origin/branchname12. See all remote branches
git branch -a13. Update local branch forcefully
git fetch --allgit reset --hard origin/master
14 .gitignore fixes
git rm -r --cached .git add .
git commit -m "fixed untracked files"
15. create a branch from previous commit
git branch <new_branch_name> <commit_id>git push origin <new_branch_name>
16. Git clone with submodules
git clone --recursive git://github.com/foo/bar.git
git submodule update --init --recursive
17. git rename a file
git mv <old-file-name> <new-file-name>git commit -m "<commit message>"
git push origin <branch-name>
No comments:
Post a Comment