Jump to content

Excuse my ignorance, stupid Git question.

ItsDaGeek

Well, here I am asking the basic of questions about git.

 

Normally, when I need to push my changes to github, I have to run

git add --all
git commit -m "Commit Comment"
git push -u origin master

 

Is there a way I can streamline this process? I have to do push to multiple repositories, at least 40 times a day per site, finding a easier way to do this would save me a hell of a lot of time.

 

Cheers!

Primary: Xeon E3-1231v3, 32GB HyperX, GTX 960

Mobile: Lenovo Thinkpad X61 running Apricity Linux

Link to comment
Share on other sites

Link to post
Share on other sites

You don't have to push all the time. Push just means that you're sending the information/update to your remote repository, if you want you can just commit everything and do one push at the end of the day, or once in a while.

 

If you want it to go faster, you can setup aliases in your terminal, I like to use "gaa" for "git add all", "gc" for "git commit", etc. 

Link to comment
Share on other sites

Link to post
Share on other sites

I'd write a python script or something like that to handle it for you

Solve your own audio issues  |  First Steps with RPi 3  |  Humidity & Condensation  |  Sleep & Hibernation  |  Overclocking RAM  |  Making Backups  |  Displays  |  4K / 8K / 16K / etc.  |  Do I need 80+ Platinum?

If you can read this you're using the wrong theme.  You can change it at the bottom.

Link to comment
Share on other sites

Link to post
Share on other sites

You could make a single word alias for each one or write a shell script for all three at once.

[Out-of-date] Want to learn how to make your own custom Windows 10 image?

 

Desktop: AMD R9 3900X | ASUS ROG Strix X570-F | Radeon RX 5700 XT | EVGA GTX 1080 SC | 32GB Trident Z Neo 3600MHz | 1TB 970 EVO | 256GB 840 EVO | 960GB Corsair Force LE | EVGA G2 850W | Phanteks P400S

Laptop: Intel M-5Y10c | Intel HD Graphics | 8GB RAM | 250GB Micron SSD | Asus UX305FA

Server 01: Intel Xeon D 1541 | ASRock Rack D1541D4I-2L2T | 32GB Hynix ECC DDR4 | 4x8TB Western Digital HDDs | 32TB Raw 16TB Usable

Server 02: Intel i7 7700K | Gigabye Z170N Gaming5 | 16GB Trident Z 3200MHz

Link to comment
Share on other sites

Link to post
Share on other sites

First, specifying -u origin master every time is unnecessary. -u is short of --set-upstream, which you only need to do the first time out push a new local tracking branch.

 

Instead, I recommend this:

git config --global push.default simple

Then you can simply run:

git push

When adding new files, use short version of git add flag:

git add -A

If you're in the top-level directory of your repository, you can just run:

git add .

When working with files that are already tracked, you can add and commit in one step with the -a flag (--all):

git commit -am "message"

So to recap, your workflow can be simplified to:

git commit -am "message" && git push

As others have suggested, you can access git commands more easily by creating Bash aliases or even a function in your .bashrc.

 

Happy coding.

Link to comment
Share on other sites

Link to post
Share on other sites

Here's a function that you can add to your .bashrc to simplify the process:

gacp()
{
  if [$# -ne 1]; then
    printf "Usage: gacp <commit_message>\n"
  else  
    git commit -am "$1" && git push
  fi
}

Fun fact: Bash will autocomplete custom function names for you, for even more typing speed.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×