git status

Undo commit and keep all files staged: git reset --soft HEAD~Undo commit and unstage all files: git reset HEAD~Undo the commit and completely remove all changes: git reset --hard HEAD~
git rm -r one-of-the-directories // This deletes from filesystem
git commit . -m "Remove duplicated directory"
git push origin <your-git-branch> (typically 'master', but not always)
gitk
git branch newBranchName
git branch

before push command

git checkout branch-name
git checkout -b branch-name

How to merge a branch to master and then delete it

git branch -D branchName//if u use lowercase d, git will ask u first to merge
git add -A

but if you want to be sure no additional files are added, just give an -n parameter as well

git add -A -n

git pull origin master

git log

git initgit .addgit commit

If you want to make use of git hub, you will have to first create a project on github then

Make sure you don’t add lisence or readme when you create the repo from github otherwise it will give an error on pushing commits Updates were rejected because the remote contains work that you do not have locally.

git remote add origin https://github.com/cubeton/mynewrepository.gitgit pull origin master  //if you already have something uploadedgit add.git commit -amgit push -u origin master

Add files under git .gitinore there is no format necessary, just file name and line breaks

apps
client
.env
node_modules

To push changes onto a new branch on GitHub, you’ll want to run git push origin yourbranchname.

after that changes can be merged into the main branch

It’s essentially shorthand for the remote repository’s URL. So, to push your changes to the remote repository, you could’ve used either the command: git push git@github.com:git/git.git yourbranchname or git push origin yourbranchname

A pull request (or PR) is a way to alert a repo’s owners that you want to make some changes to their code. It allows them to review the code and make sure it looks good before putting your changes on the master branch.

This is what the PR page looks like before you’ve submitted it:

You might see a big green button at the bottom that says ‘Merge pull request’. Clicking this means you’ll merge your changes into the master branch.

Note that this button won’t always be green. In some cases it’ll be grey, which means you’re faced with a merge conflict. This is when there is a change in one file that conflicts with a change in another file and git can’t figure out which version to use. You’ll have to manually go in and tell git which version to use.

When you are done, it’s best to delete the branch

Working with Git remotes and pushing to multiple Git repositories

exammple case: let’s say you have a Heroku git repo and you want to put that to GitHub as well

You can have as many remotes as you want, but you can only have one remote named “origin”. The remote called “origin” is not special in any way, except that it is the default remote created by Git when you clone an existing repository. You can configure a second remote, push to/pull from that remote, and setup some branches to track branches from that remote instead of origin.

Try adding a remote called “github” instead:

$ git remote add github https://github.com/Company_Name/repository_name.git# push master to github
$ git push github master
# Push my-branch to github and set it to track github/my-branch
$ git push -u github my-branch
# Make some existing branch track github instead of origin
$ git branch --set-upstream other-branch github/other-branch

Obviously the added files will be the same

Or you can make origin push to more than one git repository server at a time. (I don’t recommend as the earlier method has more control)

git remote set-url --add origin ssh://git@bitbucket.org/user/myproject.git
git remote
git push -f origin master
git remote set-url origin ssh://git@bitbucket.org/user/myproject.git

we just skipped--add

Instead of ‘origin’ you can uses your own remote name

https://github.com/cubeton/git101/tree/master/TurtorialInfo

https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners

Finding Magic.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store