Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Apr 14, 2021

git merge reset merge

  • git fetch && git checkout master
  • # You want to pull master to your branch
    • git checkout branch1 (from master)
  • git merge master (or git pull origin master)
    • CONFLICT (content): Merge conflict in site/test.py
    • --- say some conflicts & u want to move to master / branch2

    • git checkout master
      • ----> error: you need to resolve your current index first
    • git branch ## branch1
    • git reset --merge
    • git checkout master # will work

    Apr 28, 2020

    Git How to Revert a commit and push to new branch

    Say you committed files to a wrong branch
    How to revert and push new branch?

    Existing Branch
    git log --oneline
    check for commit id: E.g., e0db5f7
    git revert <commit_id>
    git push

    Create a new branch
    git checkout -b new_branch
    git checkout <commit_id> .    #this will copy commit files to local branch
    git commit
    git push


    Mar 21, 2019

    Git commands

    # Git Config

    git init

    git config user.email test@test.com

    git config user.name 'Prabhath Kota'

    git clone https://github.com/prabhathkota/Django-user-registration.git


    Checkout Branch:

    • git checkout -b test_branch
    • git branch
    • git push --set-upstream origin test_branch

    git status -s #check if any modified files

    modified:   common_utils.py

    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    ../api/log/
    misc/test_rl.py

    # stash without a name
    git stash

    # stash 
    git stash save <name_of_stash>
    stash@{0}: On develop: new_changes

    # -u if you want to stash untracked files as well
    # git stash save -u <name_of_stash>  # Dont use this

    #git stash list
    stash@{0}: On develop: new_changes

    git status -s

    # stash apply
    git stash apply stash@{0}

    # Takes the latest and apply
    git stash pop

    # Clear stash
    git stash clear

    # gitignore