git - Adding my own code to my own respository in Github error -
git - Adding my own code to my own respository in Github error -
i'm trying figure out why own code desktop repository not beingness pushed repository created in github.
i did following:
cd "/your/repo/dir" git clone https://github.com/user_aka_you/reponame # (creates /your/repo/dir/reponame) cp "/all/your/existing/code/*" "/your/repo/dir/reponame/" git add together -a git commit -m "initial commit" git force origin master and receive message:
to https://github.com/skumar225/battleship.git ! [rejected] master -> master (non-fast-forward) error: failed force refs 'https://github.com/skumar225/battleship.git' hint: updates rejected because tip of current branch behind hint: remote counterpart. integrate remote changes (e.g. hint: 'git pull ...') before pushing again. hint: see 'note fast-forwards' in 'git force --help' details. what error , how can prepare this?
you want fetch , checkout github repository not clone it.
if haven't told git you should now. can per repository or globally. minimize problems should match github information. prefer globally don't have again...
git config --global user.name "your name" git config --global user.email "your.email@example.com" setup local repository
# create directory working tree , git repository mkdir -p ~/projects/{src,git}/battleship # alter directory git repository directory cd ~/projects/git/battleship # init git repository (bare) git --git-dir ~/projects/git/battleship --work-tree ~/projects/src/battleship init add remote repository can pulled/pushed to/from
# add together remote (github) repository (upstream) git remote add together github git@github.com:skumar225/battleship.git fetch upstream (github) , checkout
for part work have have an ssh key setup , assigned ssh. doesn't have setup through github pull public repository need to force it.
# fetch upstream git fetch github # checkout master branch git checkout master # files in working tree , ready play verify working tree populated
ll ~/projects/src/my-project # local repo ready git status make changes working tree
you have local repository synced repository on github. sake of reply add together file , modify file in our working tree can commit.
note: night, caffeine fueled, coding cram session goes normally.
echo '** new file has been created!' > ~/projects/src/battleship/newfile.md echo '- [x] add together new file' >> ~/projects/src/battleship/readme.md staging changes
before can commit files must stage them. if status before , after staging can see difference.
note: must still in git directory without including --git-dir
git status git add together . git status commit local repository
finally can commit local repository!
note: if have longer message omit -m bit , open vim add together longer message.
git commit -m "this test commit" push upstream (github)
at point left pushing upstream. part cannot since isn't repository simple command:
note: part work have setup credentials in github first knows are.
git force github a trick create git easier locally
i setup alias each local repository maintain. allows me utilize git without having type out --git-dir each time or changing directory repository.
alias gitbs='git --git-dir ~/projects/git/battleship' now can utilize alias (from anywhere).
gitbs status gitbs add together . gitbs force github # etc that until next login though. create permanent add together command ~/.bashrc file.
git github
Comments
Post a Comment