Collaborate with Git – Training | Microsoft Learn

Commit and push to a newly created repository:

Navigate to folder with git cmd
Add the files in your new local repository. This stages them for the first commit.
Commit the files that you’ve staged in your local repository.
At the top of your GitHub repository’s Quick Setup page, click to copy the remote repository URL. In the Command prompt, add the URL for the remote repository where your local repository will be pushed.
Push the changes in your local repository to GitHub.

Conflict with commit to origin master?, do a pull before commit.

git config --global credential.helper wincred
git init
git add .
git commit -m "first commit"
git remote add origin remote_repos_url
git push origin master

git pull origin master


Cloning a repository:

Navigate to where you want to store the repository:

cp the url and run:

git clone

Do some code changes, here we added a new file:

Then run the below code and the repository is updated

git add .
git commit -m "from new pc"
git push origin master

Change repository and work more there:

cd t-sql
git add .
git commit -m "change dir"
git push origin master

Branch, if the branch “test” was created and we did some some changes

git branch

git add .
git commit - m "my commit"
git push origin HEAD:test


git checkout master
git merge --no-f test
git push origin master
git push origin test

Pull (will pull changes from the origin remote, master branch and merge them to the local checked-out branch)

git pull origin master

Merge conflicts

Did you get automatic merge failed; fix conflicts and then commit the result?
You did some updates local and someone did remote.

$ git pull origin master
 * branch            master     -> FETCH_HEAD
CONFLICT (content): Merge conflict in
Automatic merge failed; fix conflicts and then commit the result.

View merge conflicts

git status

If you get try to push a to big file i.e .bak for example use this cmd after you removed the file from the local repos (merged in previous commit and github rejected the push)

git lfs migrate import --include="*.csv"

Connecting to GitHub with SSH