Git Commands

Problem 1:

rejected master -> master (non-fast-forward)

you have a readme file inside git remote repo. but you don’t have that in your local repo.

;;;;; I created a github repository after creating my local git repository so I needed to accept the changes into local before pushing to github. In this case the only change was the readme file created as optional step when creating github repository. ;;;;;

REF: https://stackoverflow.com/questions/11696295/rejected-master-master-non-fast-forward

solution:


1. git init

2. git pull https://github.com/*username*/*repository*.git master
in my case: git pull https://github.com/milon27/TextViewHelper.git master

3. git add .

4. git commit -m "new commit"

5. git remote add origin https://github.com/milon27/TextViewHelper.git

6. git push -u origin master


for readme.md file check this link https://guides.github.com/features/mastering-markdown/


2.work with branches

1.create a branch
git branch branch_name
2.show all branch
git branch -a or git branch --list
3.switch branch
git checkout branch_name
4.create and checkout at a time
git checkout -b branch_name
5.push only to a branch
git push --set-upstream origin branch_name

3.problem : how to modify the commit messgea

1.very last commit (most recent)
git commit --amend -m "last commit message changed now"
2.other commit messages changes here: -i: interactive HEAD~2 : no of commit
git rebase -i HEAD~2
3.git rebase (–continue | –abort | –skip)
git rebase (--continue | --abort | --skip)

Leave a Comment

Your email address will not be published. Required fields are marked *