########################## Git Hints ########################## Download a Remote Branch to Replace a Local Branch *************************************************************** Here we are working with 2 upstream remotes #. my remote call it #. the project remote call it git co dev git br -m dev_bckup #or git br Find all remote branches and their upstream repositories, then fetch a specific remote branch from an upstream repository. Finally check out the upstream repository and create a local repository with that name. (Assumes you do not have a local repository named ) :: git br -r # git fetch git fetch upstream dev # create a new branch dev from fetched branch # git checkout -b / git co -b dev upstream/dev # push dev to origin # first delete origin/dev git push origin --delete dev # then push new dev to origin- git push git push origin dev Delete a Local and Remote Branch ******************************** :: git br -d git push --delete Create a New Branch from a Previous Branch ******************************************* :: git co -b Remove Cached Files from Git Tracking ************************************** :: git rm git rm -r Rebase ******* Git Rebase will take commits from your current working branch and apply them to the head of the base branch. Make sure master or base is latest from upstream/master and latest master is pushed up to origin :: git co latest_feature_branch # Rebase current master onto feature branch git rebase master # now latest_feature_branch can be merged with master Remove Untracked Files ************************ The command to remove untracked files is 'git clean'. Before rmoving your untracked files use the -n option to tell you what will be removed. You may changed your mind and add them to the project or put the filename in your .gitignore file. '-d' also removes untracked directories. :: git clean -d n # Output: # Would remove # Would remove If you want to permanently remove an untracked file. :: $ git clean -d -f #Output # Removing # etc. This deletes the files! Interactive mode. :: $ git clean -d -i Rename a Branch ******************* :: $ git co dev $ git br -m dev_bckup #or $ git br Use GitHub to Create a New Repository from the Command Line ************************************************************ Create local git repository. Install gh. Make sure you have your login credentials ready. :: $ gh repo create Go through a series of choices and set the remote. Use Git with Heroku CLI ************************ ``_ Update Heroku, I believe it requires a restart after the update :: heroku update Create an app in Heroku :: $ heroku create Creating app... done, ⬢ sheltered-brook-17119 https://sheltered-brook-17119.herokuapp.com/ | https://git.heroku.com/sheltered-brook-17119.git Add a remote to your local repository. Note that heroku only deploys code to the master or main branch :: $ heroku git:remote -a sheltered-brook-17119 set git remote heroku to https://git.heroku.com/sheltered-brook-17119.git # check the remote was created $ git remote -v heroku https://git.heroku.com/sheltered-brook-17119.git (fetch) heroku https://git.heroku.com/sheltered-brook-17119.git (push) # rename a remote if you wish $ git remote rename heroku heroku-staging