GithubHelp home page GithubHelp logo

git-tips's Introduction

https://marklodato.github.io/visual-git-guide/index-pl.html?no-svg

git-tips

  1. reset local branch to it's origin version
git fetch origin
git reset --hard origin/master
  1. reset file version to repository version
git checkout {branchname} -- {path-to-file}
  1. Check if base branch has ahead commits of subbranch
git rev-list --count branch1..basebranch

if return = 0, it means that there is no changes ahead

  1. Delete branch (locally and remote):
git push -d <remote_name> <branch_name>
git branch -d <branch_name>
  1. Cherry pick

Make sure you are on the branch you want to apply the commit to.

git checkout master

Execute the following:

git cherry-pick <commit-hash>
  1. Create subbranch from branch
git checkout -b myFeature baseBranch
  1. Add alias for command:
git config --global alias.st status
  1. Get list of aliases:
git config --get-regexp alias
  1. cherry-pick but change commit message:
git cherry-pick -e <hash>
  1. Add remote to local repo:
git remote add origin [email protected]:User/UserRepo.git
git push -u origin master
  1. Change remote origin
git remote remove origin
git remote add origin ORIGIN_URL
  1. My git aliases list:
git config --global alias.st status
git config --global alias.cmt commit
git config --global alias.p push
git config --global alias.a add
git config --global alias.co checkout
git config --global alias.pl pull
git config --global alias.mg merge
  1. Reset all changed files to origin branch state
git checkout -- .
  1. See changes which is in main but not in my local branch:
    git log HEAD..origin/main
    

3 important rules to work with GIT in team:

1. Resolve conflicts only when you understand why they have arisen.
2. Always check the list of commits you push
3. Notified all developers if you have done push force.
  1. change remote origin url

First - check current remote url

git remote -v

Second actual change:

git remote set-url origin [email protected]:myuser/my-project.git

git-tips's People

Contributors

sukhoy94 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

git-tips's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.