Alejandro G. Carlstein Ramos Mejia Blog



Git: Useful Commands

05.10.2016, Git, by .

Below are a few most common commands that are useful to know:

  • Clean up your branch list of branches that doesn’t exist any longer on the remote repository: 
    • git fetch --prune
  • Delete local branch in local repository:
    • git branch -D <branch_name>
  • Delete remote branch in remote repository:
    • git push origin --delete <branch_name>
  • Show which files are tracked or not:
    • git status
  • Track all changes you have done so far:
    • git add .
  • Commit your tracked changes to your local repository:
    • git commit
  • Submit your tracked changes, saved in your local repository, to the remote repository:
    • git push -u origin <branch_name>
  • Merge one branch into your current branch:
    • git merge --no-ff <other_branch>
  • Change branches: 
    • git checkout <branch_name>
  • Create a new branch from current branch:
    • git checkout -b <new_branch_name>
  • Save in the stash your files changes:
    • git stash
  • Apply your file changes saved in the stash into your current branch:
    • git stash pop 

      or

    • git stash apply
  • History of an specific file that you don’t know where reside:
    • git log --all "**/file.groovy"
  • Stash untracked files without staging them (Version 1.7.7+):
    • git stash save -u
  • Get all the stuff from remote repository:
    • git pull
  • Problems when pulling? Asking you to retry a link issue? Try the garbage collector
    • git gc
  • Reset local branch to origin (remote) version
    • git reset --hard origin/<branch_name>

© 2016, Alejandro G. Carlstein Ramos Mejia. All rights reserved.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

*

Click to Insert Smiley

SmileBig SmileGrinLaughFrownBig FrownCryNeutralWinkKissRazzChicCoolAngryReally AngryConfusedQuestionThinkingPainShockYesNoLOLSillyBeautyLashesCuteShyBlushKissedIn LoveDroolGiggleSnickerHeh!SmirkWiltWeepIDKStruggleSide FrownDazedHypnotizedSweatEek!Roll EyesSarcasmDisdainSmugMoney MouthFoot in MouthShut MouthQuietShameBeat UpMeanEvil GrinGrit TeethShoutPissed OffReally PissedMad RazzDrunken RazzSickYawnSleepyDanceClapJumpHandshakeHigh FiveHug LeftHug RightKiss BlowKissingByeGo AwayCall MeOn the PhoneSecretMeetingWavingStopTime OutTalk to the HandLoserLyingDOH!Fingers CrossedWaitingSuspenseTremblePrayWorshipStarvingEatVictoryCurseAlienAngelClownCowboyCyclopsDevilDoctorFemale FighterMale FighterMohawkMusicNerdPartyPirateSkywalkerSnowmanSoldierVampireZombie KillerGhostSkeletonBunnyCatCat 2ChickChickenChicken 2CowCow 2DogDog 2DuckGoatHippoKoalaLionMonkeyMonkey 2MousePandaPigPig 2SheepSheep 2ReindeerSnailTigerTurtleBeerDrinkLiquorCoffeeCakePizzaWatermelonBowlPlateCanFemaleMaleHeartBroken HeartRoseDead RosePeaceYin YangUS FlagMoonStarSunCloudyRainThunderUmbrellaRainbowMusic NoteAirplaneCarIslandAnnouncebrbMailCellPhoneCameraFilmTVClockLampSearchCoinsComputerConsolePresentSoccerCloverPumpkinBombHammerKnifeHandcuffsPillPoopCigarette