esther-86 / Work-Notes

0 stars 0 forks source link

Git #3

Open esther-86 opened 3 years ago

esther-86 commented 3 years ago

SSH: https://medium.com/codex/clone-github-private-repository-using-ssh-on-mac-acc9110d1cfe

esther-86 commented 3 years ago
  1. Clone this repository in your local machine git clone git@gitlab.medable.com:automation/medable-automation-kt.git
  2. Checkout the branch named: feature/kt-exercise https://support.atlassian.com/bitbucket-cloud/docs/check-out-a-branch/
    >>> cd medable-automation-kt 
    >>> git branch -a
    * dev
    remotes/origin/HEAD -> origin/dev
    remotes/origin/dev
    remotes/origin/feature/kt-exercise
    remotes/origin/master
    >>> git checkout kt-exercise 
    error: pathspec 'kt-exercise' did not match any file(s) known to git
    >>> git checkout feature/kt-exercise
    Branch 'feature/kt-exercise' set up to track remote branch 'feature/kt-exercise' from 'origin'.
    Switched to a new branch 'feature/kt-exercise'
    >>> git branch
    dev
    * feature/kt-exercise
  3. Create and push a new branch named: feature/kt-exercise-{your-name-here} https://stackoverflow.com/questions/1519006/how-do-you-create-a-remote-git-branch
    >>> git checkout -b feature/kt-exercise-esther
    Switched to a new branch 'feature/kt-exercise-esther'
    >>> git push -u origin feature/kt-exercise-esther
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    remote: 
    remote: To create a merge request for feature/kt-exercise-esther, visit:
    remote:   ...
    * [new branch]      feature/kt-exercise-esther -> feature/kt-exercise-esther
    Branch 'feature/kt-exercise-esther' set up to track remote branch 'feature/kt-exercise-esther' from 'origin'.

    https://stackoverflow.com/a/37482577/5885721 When you want to commit something in your branch, be sure to be in your branch. You can see all branches created by using git branch

    >>> git branch
    dev
    feature/kt-exercise
    * feature/kt-exercise-esther
esther-86 commented 2 years ago

If you have been making commits on your main branch while you coded, but you now want to move those commits to a different branch, this is a quick way:

Copy your current history onto a new branch, bringing along any uncommitted changes too:

git checkout -b Now force the original "messy" branch to roll back: (without switching to it)

git branch -f For example:

git branch -f master origin/master or if you had made 4 commits:

git branch -f master HEAD~4

https://stackoverflow.com/a/35357274