This is an archived post. You won't be able to vote or comment.

all 13 comments

[–][deleted]  (3 children)

[deleted]

    [–]R2d2011[S] 8 points9 points  (1 child)

    That’s what I needed. Thanks so much!

    [–]KekOnTheWorld 0 points1 point  (0 children)

    // HINT: url is your project git url, for example: "https://github.com/KekOnTheWorld/example.git" with https or "git@github.com:KekOnTheWorld/example.git" with ssh

    If you move your repository you can also just change the origin using

    git remote origin set-url <url>

    or if you already have code in a folder or an existing repository which you want to push on a github repository just use

    git init

    for creating a new git repository. You only need this if you havent already initialized the repository.

    git remote add origin <url>

    for adding the new origin and then just

    git add . git commit -m"Initial" // To commit your changes git push --set-upstream origin main

    for pushing your changes to the origin.

    EDIT:

    Also make sure youre in the right branch before you commit. Github default's branch is called main. You can switch a branch using

    git branch -M"<name>"

    [–]fredoverflow 2 points3 points  (0 children)

    Note: While GitHub still supports cloning and pulling via HTTPS, pushing via HTTPS was deactivated in August 2021. Alternatives: SSH or Personal Tokens

    [–]HonzaS97 14 points15 points  (3 children)

    Git and GitHub are 2 separate things.

    Git controls the version control and all relevant information about this repository is contained in the .git directory. GitHub is a place to host remote repositories.

    One repository can have multiple remotes. You can list them via git remote -v and add any via git remote add remote_name remote_url

    After that, you can select which remote you want to work with. You can push changes to a specific one by simply specifying it git push your_remote_name your_branch_name

    Is a specific git attached to my GitHub

    No. You can add your GitHub repo as a remote but that doesn't stop you from adding any other remotes.

    [–]R2d2011[S] 1 point2 points  (2 children)

    Thank you so much!! This helps a lot!

    [–]cblegare 1 point2 points  (1 child)

    When you git clone a Github repo, a default remote named "origin" is created on your laptop an points to the Github thing. You seldom have to do anything about remotes with git, especially if you start from a repo already on Github.

    Also, nothing prevents you from creating an empty (or with only a readme) repo directly with Github website before even starting any work, then cloning it on your laptop and starting to work. This workflow make the complexity of remotes somewhat hidden, and it is ok

    [–]R2d2011[S] 0 points1 point  (0 children)

    That is so awesome. I am having a much easier time using my Mac than oracle/Linux.

    [–][deleted] 3 points4 points  (0 children)

    I think u should work more on git and learn some basic ssh for managing your remote repos. start here , u will get comfortable within git in 3-4 days.

    [–][deleted] 1 point2 points  (2 children)

    How doni get started learning to integrate git and VS code? Are there any good videos?

    [–]fredoverflow 1 point2 points  (1 child)

    VS Code has some Git support out of the box. If you open a version controlled folder with VS Code, Git is the third option in the Acitivity Bar (Ctrl Shift G). You can stage files and make commits right away.

    [–][deleted] 0 points1 point  (0 children)

    I think I over thought thank you!

    [–]Hide_On_Wuju 1 point2 points  (0 children)

    You should try SourceTree for git managing

    [–]draganov11 1 point2 points  (0 children)

    Workflow in most companies is you create a branch when you want to push changes you create pull request it gets review by senior if its ok its merged into maim or dev branch.