Skip to content

this will guide users on how to create, pull, clone, push on Github from/to their local repository git

License

Notifications You must be signed in to change notification settings

deesynertz/how_to_create_rep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

how_to_create_rep

This will guide user on how to create, pull, clone, and push repo on Github from/to their local repository

Quick setup — if you’ve done this kind of thing before

Get started by creating a new file or uploading an existing file. GitHub recommends every repository include a README, LICENSE, and .gitignore.

For those who created a new repository on the command line

make sure you are in a folder that will have a working project on terminal for Mac and Linux and cmd or power-shell or gitbat then run the following command.

steps

git init
git add README.md
git commit -m "any message you want to add as commit"
git branch -M master
git remote add origin <Your Github rep URL> e.g https://github.com/deesynertz/how_to_create_rep.git

if Error: failed to push some refs to <url.git> occured Solution: Here

in case you have remote origin but in any substance you need to change the remote URL you have to use the below code as commented by @shebyclassic2018

git remote set-url origin <Your new Github repo URL>
git push -u origin master

but you can use the -f flag instead of -u during the push activity

Push an existing repository from the command line

git remote add origin <Your GitHub rep URL> e.g https://github.com/deesynertz/how_to_create_rep.git
git branch -M master
git push -u origin master

if any fatal: refusing to merge unrelated histories occured

Solution

git pull origin master --allow-unrelated-histories

Some basic Git commands are:

git status
git add
git commit "any message you want to add as commit"
git clone <Your GitHub rep URL> e.g https://github.com/deesynertz/how_to_create_rep.git
git pull
Note: 
# Some beginners as i was before are facing the problem of quitting the git log, and I realized that is quite simple to quit the log by pressing one character on your keyboard just one );

q

BRANCH

See What Branch You're On Run this command:

git status

List All Branches

NOTE:

The current local branch will be marked with an asterisk (*)

To see local branches, run this command:

git branch

To see remote branches, run this command:

git branch -r

To see all local and remote branches, run this command:

git branch -a

Create a New Branch Run this command (replacing my-branch-name with whatever name you want):

git checkout -b <my-branch-name>

Set upstream branch using git push

git push --set-upstream <remote> <branch>

How do I delete a local branch in Git?

Git makes managing branches really easy - and deleting local branches is no exception:

git branch -d <local-branch>

Try to synchronize your branch list using

The -p flag means "prune". After fetching, branches that no longer exist on the remote will be deleted.

git fetch -p

In some cases, Git might refuse to delete your local branch: when it contains commits that haven't been merged into any other local branches or pushed to a remote repository. This is a very sensible rule that protects you from inadvertently losing commit data.

  git branch -D <local-branch>

The question is How do I delete a remote branch in Git ?

git push origin --delete <remote-branch-name>
git remote set-url --delete --push  origin https://github.com/shebyclassic2018/ngatahomes_backup.git
Note: 
# If you have deleted a branch on GitHub and it still appears when you run the command to view all branches, it's possible that the local repository still has a reference to the deleted branch. To remove the deleted branch permanently, you can try the following steps:

Update your local repository with the latest changes from GitHub by running the following command:
git fetch --prune

The above command will remove any references to remote branches that no longer exist on GitHub.

SOME RULES TO FOLLOW BEFORE PUSH SOME CHANGES TO GITHUB

These are very important rules for teamwork.

  • stage your changes

    git add .
  • Commit your work first.

    git commit -m "<any description >"
  • Pull first before pushing your changes

      git pull
  • Now push your changes to git

      git push

Note: make sure you are in a project directory on your local computer.

x:/-directory/project-directory >

THE GOLDEN RULES OF VERSION CONTROL

according to TOWER

No. 4: Never Commit Half-Done Work

You should only commit code when it’s completed. This doesn’t mean you have to complete a whole, large feature before committing. Quite the contrary: split the feature’s implementation into logical chunks and remember to commit early and often. But don’t commit just to get half-done work out of your way when you need a "clean working copy". For these cases, consider using Git’s “Stash” feature instead.

Support

deesynertz


LISENCE AND CONTACT

General badge

General badge

General badge

@deesynertz 👍 Enjoy using Github for the best software version control - it's ready to merge! :shipit:

This is an image

About

this will guide users on how to create, pull, clone, push on Github from/to their local repository git

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published